Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

log4j: log4j:WARN No appenders could be found for logger (org.apache.commons.digester

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder what causes this error message:

log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.

but when I do:
log.info(......)
I can see the output on the console, any idea?
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The message means that the log4j.properties file was not found. Printing logging output to the console (or rather System.out) is the fallback if the logging is not otherwise initialized.
 
Kamal Ahmed
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This indicates that if you look in your log4j properties file, the Logger is not assigned an appender, here is a sample log4j.properties that works, compare this with the one you have:

log4j.rootLogger=DEBUG, testAppender
log4j.appender.testAppender=com.webmethods.sc.logging.log4j.WmDailyFileAppender
log4j.appender.testAppender.file=log/test1.log
log4j.appender.testAppender.datePattern='.'yyyy-MM-dd_HH_mm
log4j.appender.testAppender.Append=false
log4j.appender.testAppender.layout=com.webmethods.sc.log4j.PatternLayout
log4j.appender.testAppender.layout.ConversionPattern=%m%n

#Prevent internal log4j DEBUG messages from polluting the output.
log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
log4j.logger.org.apache.log4j.config.PropertySetter=INFO
log4j.logger.org.apache.log4j.FileAppender=INFO
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok....this is my log4j.properites file:

log4j.rootLogger=ERROR, stdout, runwayAppender
# SqlMap logging configuration...
log4j.logger.com.ibatis=DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.logger.java.sql.ResultSet=DEBUG
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n


where exactly should I place it? (I'm still getting the warning)
thanks!
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to place it in the classpath of the application which is using log4j's logger.
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Jaikiran,

I'm not sure what you meant by:

You will have to place it in the classpath of the application which is using log4j's logger.


I have a struts application, where should I place it? under the web-inf/src?

thanks for any advise
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In an application that is deployed, you wont be having a WEB-INF/src folder. Instead you will be having a WEB-INF/classes folder. You can place the log4j.properties (or log4j.xml) in this WEB-INF/classes folder of your application.

Also, see if enabling log4j debug flag helps
 
rajareddy dodda
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is the name of LOg4j.properties file is stanfdard. i tryed with the file name changed by config.properties it is giving me following error. please let me know the standard of the file name, is the name must be log4j.properties ?. thanks in advance.


no appender added.


Thanks
RajaReddy.
 
shyam sunder prasad
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got same Waring in my application.then i placed log4j.xml or log4j.properties file in class path (/WEB-INF/classes/).

i.e , WEB-INF/classes/log4j.xml
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry to awaken "dead" threads, however I have encountered a similar problem, and, I am still stuck. I'm using Eclipse 3.6.2.

log4j.properties.


This is placed where the source files (.java files) are located.
 
Anita Kulkarni
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just solved this issue by adding the appender. Seems like you already do have it. Try putting the log4j.prop in WEB-INF/classes dir or into WEB-INF itself.
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anita Kulkarni wrote:I just solved this issue by adding the appender. Seems like you already do have it. Try putting the log4j.prop in WEB-INF/classes dir or into WEB-INF itself.


Thanks, it's a good tip, but I don't run Tomcat here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic