First up - yes, I have read the multiple questions & answers on this topic, and can't get any of the solutions within those to help me. I'm not running Tomcat or JBoss and I don't have a web.xml
file to change. I'm using Java 6.0 and log4j-1.2.8.jar
.
I am creating a runnable jar file with IDEA IntelliJ with jar libraries packaged separately and linked via the manifest. I am running my code on a Linux server thus:
me@server:/mydir> java -jar code/myjar.jar log4j:WARN No appenders could be found for logger (FactoredEventsForTrna). log4j:WARN Please initialize the log4j system properly.
My log4j configuration file (which I've placed both in mydir
and mydir/code
, just in case) is:
## Logger configure file for myproject log.dir=log/ datestamp=yyyy-MM-dd/HH:mm:ss.SSS log4j.rootLogger=TRACE, file, proappender, console log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.maxFileSize=1GB log4j.appender.file.maxBackupIndex=5 log4j.appender.file.File=log/mydebug.log log4j.appender.file.threshold=TRACE log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{${datestamp}} %5p: %c{2} - %m%n log4j.appender.proappender=org.apache.log4j.RollingFileAppender log4j.appender.proappender.maxFileSize=5GB log4j.appender.proappender.Threshold=INFO log4j.appender.proappender.File=log/myinfo.log log4j.appender.proappender.layout=org.apache.log4j.PatternLayout log4j.appender.proappender.layout.ConversionPattern=%d{${datestamp}} %5p: %c{2} - %m%n log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.Threshold=DEBUG log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%d{${datestamp}} %5p: %c{2} - %m%n
And I have created the log/
directory in mydir
and mydir/code
, again, just in case.
Any ideas?
Why do I see a warning about "No appenders found for logger" and "Please configure log4j properly"? This occurs when the default configuration files log4j. properties and log4j. xml can not be found and the application performs no explicit configuration.
The file is named log4j. properties and is located in the $DGRAPH_HOME/dgraph-hdfs-agent/lib directory. The file defines the ROLLINGFILE appenders for the root logger and also sets the log level for the file. The level of the root logger is defined as INFO and attaches the ROLLINGFILE appender to it.
There are many possible options for specifying your log4j configuration. One is for the file to be named exactly "log4j.properties" and be in your classpath. Another is to name it however you want and add a System property to the command line when you start Java, like this:
-Dlog4j.configuration=file:///path/to/your/log4j.properties
All of them are outlined here http://logging.apache.org/log4j/1.2/manual.html#defaultInit
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