Logback.xml and application launch from JetBrains IDEA IDE

When I develop an application in IDEA, where should I put logback.xml to influence the application?

It seems that when you start / debug IDEA, don't make any jars and don't call Maven to create something. Does it execute main () directly from the compiled * .class file? If so, where can I put logback.xml so that it has an effect?

+6
source share
1 answer

logback.xml should be available in the root directory of your CLASSPATH. When you start the application, the full CLASSPATH is printed from the very beginning. When I put logback.xml in /src/main/resources (Maven project), it works without any problems. Also, having it in /src/test/resources with the name logback-test.xml has a presence.

Just run:

 getClass().getClassLoader().getResource("/logback.xml"); 

And look if it will return anything or null .

If you are not working with a Maven project, open the project structure ( Ctrl + Alt + Shift + S ) and add to the modules selection folder containing logback.xml and mark it as sources (blue icon).

+15
source

Source: https://habr.com/ru/post/885613/


All Articles