I am trying to capture the logs using log4j in Java. The executeable is in linux envirnment and it displays the logging message, however, it is not writing into the log file. I am using log4j.xml and this is what I have so far
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="LocalFileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="logs/error.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="500KB" />
<param name="maxBackupIndex" value="1" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] - %m%n"/>
</layout>
</appender>
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.SimpleLayout"/>
</appender>
<root>
<priority value ="Debug" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
I am not clear how the java program knows where the xml file is located. I think that is the problem. And, this is how I setup in the code,
log = Logger.getLogger(MyClass.class);
BasicConfigurator.configure();
Any help would be appreicate it. Thanks.