Reputation: 61
I have my log4j.properties file as below:
log4j.rootLogger=WARN, DebugAppender
#Debug logging
log4j.appender.DebugAppender=org.apache.log4j.RollingFileAppender
log4j.appender.DebugAppender.Threshold=WARN
log4j.appender.DebugAppender.File=activityLog.log
log4j.appender.DebugAppender.MaxFileSize=200KB
log4j.appender.DebugAppender.MaxBackupIndex=5
log4j.appender.DebugAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.DebugAppender.layout.ConversionPattern=%d{DATE} %t - %m%n
The file is added in the classpath and in src/resources folder.... my project is a maven project and I am using springshell technology so that my application runs on a command prompt... everything works perfect but when I execute a particular command in my application it gives me below warning:
log4j:WARN No appenders could be found for logger (com.gedas.rvs.data.net.ClientAuthenticationType).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Can you please help me about what am I doing wrong?
Upvotes: 2
Views: 1475
Reputation: 1
It seems it requires file appender. check the log properties files again. Here is my log properties file, have a look.
# Root logger option
log4j.rootLogger=DEBUG, file
# Redirect log messages to console
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\\log4j-application.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.logger.org.hibernate.hql=debug
log4j.logger.org.hibernate.type=trace
Instead of only debug appender, add other lines too and try. It might work!!
Upvotes: 0
Reputation: 24885
You are definning an appender (you are explaining log4j where and how to write the messages to) but you do not define which categories (the "name" given to the loggers in your program) should use it.
This tells log4j that all of the categories (rootLogger
) should use DebugAppender to write messages of severity DEBUG
or higher
# Root logger option
log4j.rootLogger=DEBUG, DebugAppender
Alternatively, if you have a logger called example.org.MyClass
, you could add
log4j.example.org.MyClass=INFO, DebugAppender
or
log4j.example.org=INFO, DebugAppender
to send INFO
and above messages to the appender.
Upvotes: 1