I am trying to use log4j logging framework in a java desktop application.
When I run the code I am getting a message
log4j: log4j:WARN No appenders could be found for logger
I googled for the above error and found that it occurs when the log4j.properties file is not found by the app.
I am creating the desktop app using Eclipse. Currently log4j.properties is within the same folder that contains the source (in ‘src’ folder). Where should I put this file to make it work properly?
log4j will use a Default Initialization Procedure to find your configuration file. The documentation notes:
The preferred way to specify the default initialization file is through the log4j.configuration system property
If this property is not set – log4j will look at the classpath. In your case you have to place the file in the
srcdirectory (assumed that the content will be put in the classes path while you build the system). If you use maven place the file to thesrc/main/resourcesdirectory.As you placed your file to the src directory check, that the file get transferred to the top level directory of your compiled classes.