Mike Blake-Knox
2004-08-11 18:47:28 UTC
I'm having difficulties configuring log4j with the DOMConfigurator. The
problem is basically that the configuration file seems to be ignored. (The
sysinternals' Filemon tools makes me believe that the configurator has
actually found and read the file but the layout that's displayed isn't what
is in the configuration file.
I'm trying to use the "trivial.java" example and have replaced the first few
lines of the trivial class with:
import org.apache.log4j.xml.DOMConfigurator;
public class Trivial {
static Logger cat = Logger.getLogger(Trivial.class.getName());
public static void main(String[] args) {
DOMConfigurator.configure("C:\\temp\\chainsaw2\\logging-log4j\\examples\\src
\\trivial\\log4jconfig.xml");
NDC.push("Client #45890");
The log4jconfig.xml file contains:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'
configDebug="true">
<appender name="R" class="org.apache.log4j.RollingFileAppender">
<param name="MaxFileSize" value="100KB" />
<param name="Append" value="true" />
<param name="File" value="c:/temp/routetext.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="TEST%-5p %c{2} - %m\n"/>
</layout>
</appender>
<appender name="TEMP" class="org.apache.log4j.ConsoleAppender">
<param name="Append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="test%-5p %c{2} - %m\n"/>
</layout>
</appender>
<root>
<appender-ref ref="R" />
<appender-ref ref="TEMP" />
</root>
</log4j:configuration>
Running the program results in console output that doesn't include the
"test" text from the pattern and the c:/temp/routetext.log file isn't
created.
Any suggestions?
Thanks.
Mike Blake-Knox
email: MBlake-***@tsystsol.com
TSYS Office: (706) 644-3643
cellphone: (706) 570-4641
problem is basically that the configuration file seems to be ignored. (The
sysinternals' Filemon tools makes me believe that the configurator has
actually found and read the file but the layout that's displayed isn't what
is in the configuration file.
I'm trying to use the "trivial.java" example and have replaced the first few
lines of the trivial class with:
import org.apache.log4j.xml.DOMConfigurator;
public class Trivial {
static Logger cat = Logger.getLogger(Trivial.class.getName());
public static void main(String[] args) {
DOMConfigurator.configure("C:\\temp\\chainsaw2\\logging-log4j\\examples\\src
\\trivial\\log4jconfig.xml");
NDC.push("Client #45890");
The log4jconfig.xml file contains:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'
configDebug="true">
<appender name="R" class="org.apache.log4j.RollingFileAppender">
<param name="MaxFileSize" value="100KB" />
<param name="Append" value="true" />
<param name="File" value="c:/temp/routetext.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="TEST%-5p %c{2} - %m\n"/>
</layout>
</appender>
<appender name="TEMP" class="org.apache.log4j.ConsoleAppender">
<param name="Append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="test%-5p %c{2} - %m\n"/>
</layout>
</appender>
<root>
<appender-ref ref="R" />
<appender-ref ref="TEMP" />
</root>
</log4j:configuration>
Running the program results in console output that doesn't include the
"test" text from the pattern and the c:/temp/routetext.log file isn't
created.
Any suggestions?
Thanks.
Mike Blake-Knox
email: MBlake-***@tsystsol.com
TSYS Office: (706) 644-3643
cellphone: (706) 570-4641