Log4j collects invalid properties file

There are 2 log4j.properties files in my classpath. I need both of them. One of them is necessary for the library that I use, and the other for my code. When I run my jar file, it can read the properties used by the library, but it does not read my own properties file. How can I get it to read my log4j without using the PropertytConfigurator in all of my source files? Is there a way to configure it so that it uses both properties files together?

+3
source share
3 answers

To answer your first question, you can point it to your own file by specifying its unique name and adding the following system property when the application starts.

-Dlog4j.configuration=path_to_my_properties_file

, 2 , .

+4

log4j.properties, , ( ).

( ?) .properties .

+3

All entries go to one properties file. Inside this file, you can distinguish between your own classes and the library logging configuration.

+1
source

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


All Articles