2

I am getting the following error while running a struts application.

13/04/19 12:42:21 log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources).
13/04/19 12:42:21 log4j:WARN Please initialize the log4j system properly.
13/04/19 12:42:21 log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

My log4j.properties file is:

log4j.threshold=ALL
log4j.rootLogger=ALL,DebugAppender,InfoAppender,RECEIPTAppender
#log4j.rootLogger=DEBUG,DebugAppender
log4j.category.DebugAppender.access=DEBUG
log4j.appender.DebugAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DebugAppender.Threshold=DEBUG
log4j.appender.DebugAppender.File=C:/APWD/ServerLogs/debug/assampwd.log
log4j.appender.DebugAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.DebugAppender.layout.ConversionPattern=%d |[%t]| %-5p |%c |- |%m|%n
#log4j.rootLogger=INFO,InfoAppender
log4j.category.InfoAppender.access=INFO
log4j.appender.InfoAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.InfoAppender.Threshold=INFO
log4j.appender.InfoAppender.File=C:/APWD/ServerLogs/debug/assampwd.log
log4j.appender.InfoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoAppender.layout.ConversionPattern=%d |[%t]| %-5p |%c |- |%m|%n
#log4j.logger.com.ctmis.hibernate=ERROR, RECEIPTAppender
log4j.category.RECEIPTAppender.access=ERROR
log4j.appender.RECEIPTAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RECEIPTAppender.Threshold=ERROR
log4j.appender.RECEIPTAppender.File=C:/APWD/ServerLogs/debug/assampwd.log
log4j.appender.RECEIPTAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.RECEIPTAppender.layout.ConversionPattern=%d |[%t]| %-5p |%c |- |%m|%n

My log4j.properties file is in WEB-INF folder. I have found similar topics in stackoverflow, but didnot work out for me, so I post it. Would really appreciate if someone can help me out, Its a warning message, but causing some module not working in the application.

Thanks

2 Answers2

2

Your log4j.properties file needs to be in the root of your classpath. Copy the file into the WEB-INF/classes folder inside your war file.

If you are using Maven, this should involve moving your file into the src/main/resources folder of your project before running the packaging command.

Community
  • 1
  • 1
seanhodges
  • 17,426
  • 15
  • 71
  • 93
  • I have kept the log4j.properties inside WEB-INF/classes folder, but did not work out for me, don't know what else could be the reason for the warning – user2007374 Apr 20 '13 at 07:58
  • Are you sure it's definitely in the correct place in your final war file? Unpack and inspect the contents of your build, I suspect your log4j.properties file is being excluded. – seanhodges Apr 21 '13 at 14:51
  • yes, i have double checked that the log4j.properties and log4j.xml file both are inside the WEB-INF/classes folder – user2007374 Apr 23 '13 at 09:02
0

The log4j configuration file needs to be in the root of the classpath. In netbeans, when you create a web application project, the path is src\java. You can see the source packages folders with a right click on the project -> Properties -> soruces. You can place the file in src\java folder or make a new folder and add it from the project properties menu.

JHCS
  • 57
  • 1
  • 7