log4j:WARN No appenders could be found for logger

2019-01-21 12:29发布

This question already has an answer here:

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?

标签: java log4j
7条回答
Lonely孤独者°
2楼-- · 2019-01-21 13:09

You will find de log4j.properties in solr/examples/resources.

If you don't find the file, i put it here:

#  Logging level
solr.log=logs/
log4j.rootLogger=INFO, file, CONSOLE

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender

log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %c %x \u2013 %m%n

#- size rotation with log cleanup.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=4MB
log4j.appender.file.MaxBackupIndex=9

#- File to log to and log format
log4j.appender.file.File=${solr.log}/solr.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; %C; %m\n

log4j.logger.org.apache.zookeeper=WARN
log4j.logger.org.apache.hadoop=WARN

# set to INFO to enable infostream log messages
log4j.logger.org.apache.solr.update.LoggingInfoStream=OFF

Regards

查看更多
登录 后发表回答