Should I specify an absolute filepath as I have done or one relevant to my app root? I think what I'm doing actually works because I get no message in the tomcat logs saying log4j was not set up correctly, however...
4) The java code then attempts to do this: Logger logger = Logger.getLogger(this.getClass()); logger.info("JS$ This is a test info log message:" + System.currentTimeMillis());
Again no exception is thrown but my log message DOES NOT APPEAR anywhere!! nor is a log file created.
Here is the actual config file located at C:\log4j.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- Change the next value to true to prevent log file overwrite --> <param name="Append" value="false"/> <param name="MaxFileSize" value="100MB"/> <param name="MaxBackupIndex" value="2"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %p %l- %m%n"/> </layout> </appender>
<root> <!-- Adjust Log Level on next line --> <priority value ="info"/> <appender-ref ref="appender"/> </root>
I'm sure I'm doing something wrong. It seems very odd to me to specify absolute file paths in a) the call to tell DOMConfigurator where the log4j.xml file is and b) the <param name="File" value="C:\logfile.txt"/> attribute in the xml config file.
Could anyone see what I'm doing wrong. I have tried playing round with this for over a day now to no avail... :0(
I'd very much appreciate some help. Regards, John
posted 14 years ago
ok ok i admit i was too long winded. here is the abbreviated post:
For application level log4j logging, if i put my log4j.xml file in app_root/WEB-INF/classes/ do I still need to call DomConfigurator.configure("filename") and if so, what filepath do I pass to this call? Relative or absolute?
In my log4j.xml file, when I specify the target log file location do i put a relative or absolute filepath?
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!