wood burning stoves 2.0*
The moose likes Struts and the fly likes struts 2 and log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 and log4j" Watch "struts 2 and log4j" New topic
Author

struts 2 and log4j

francis varkey
Ranch Hand

Joined: Sep 13, 2005
Posts: 169
Hi,
I have integrated log4j (log4j-1.2.6.jar) into my struts2 (struts.2.2.3) application . But it is not working. Getting following warning.


log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
log4j:WARN Please initialize the log4j system properly

I have put my log4j.xml into src folder od web application. I am working on windows machine

log4j.xml
------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="INFO" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss:SSS} %-5p [%c{1}] %M %m %n" />
</layout>
</appender>

<appender name="fileAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="Threshold" value="INFO" />
<param name="File" value="E:\\logs\\test\\test.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss:SSS} %-5p [%c{1}] %M %m %n" />
</layout>
</appender>

<logger name="com.test" additivity="false" >
<level value="debug"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>

</log4j:configuration>
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8876
    
    8

francis varkey wrote:
I have put my log4j.xml into src folder od web application. I am working on windows machine


The log4j configuration file has to be on the classpath of the web app at run time. Does your build copy the file into your EAR or WAR?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
francis varkey
Ranch Hand

Joined: Sep 13, 2005
Posts: 169

Yes. It is in my war file
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

It's not able to find the appenders in the above. Try with log4j.properties.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts 2 and log4j