After adding log4j to my application I get the following output every time I execute my application:
log4j:WARN No appenders could be found for logger (slideselector.facedata.FaceDataParser). log4j:WARN Please initialize the log4j system properly.
It seems this means a configuration file is missing.
Where should this config file be located and what is a good start content?
I’m using plain java for developing a desktop application. So no webserver etc…
Log4jby default looks for a file calledlog4j.propertiesorlog4j.xmlon the classpath.You can control which file it uses to initialize itself by setting system properties as described here (Look for the “Default Initialization Procedure” section).
For example:
Will cause
log4jto look for a file called customName on the classpath.If you are having problems I find it helpful to turn on the log4j.debug:
It will print to System.out lots of helpful information about which file it used to initialize itself, which loggers / appenders got configured and how etc.
The configuration file can be a java properties file or an xml file. Here is a sample of the properties file format taken from the log4j intro documentation page: