Is there any way to specify the logback configuration file to use in a JUnit run by Spring?
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/my/app/springConfiguration.xml")
public class MyTest {
private static final Logger logger = LoggerFactory.getLogger(MyTest.class);
@Autowired
Something something;
}
Now, I have got logback.xml and multiple of them. There is one that is supposed to run in prod and then there is one that I want this test to pick up. Is there a easy way to do it?
Edit : This question is specific to the case when I am running the JUnit from my Eclipse. I am working on Eclipse 4.3 on windows 7.
Pass the location as a JVM argurment on the configuration that runs your tests in eclipse.
-Dlogback.configurationFile="fullpathtofile\logback.xml"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With