xml - How to redirect system out print to FileAppendar in apache log4j -
i have implemented log4j application, logs written in file.now, have system out have wanted printed in same log file.here have till now
<!doctype log4j:configuration system "log4vj.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <!-- general application log --> <appender name="console" class="org.apache.log4j.consoleappender"> <param name="target" value="system.out"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %-5p %30.30c - %m%n"/> </layout> </appender> <appender name="default" class="org.apache.log4j.rollingfileappender"> <param name="file" value="${log.dir}/logs/debug.txt" /> <param name ="append" value="true"/> <errorhandler class="org.apache.log4j.varia.fallbackerrorhandler"> <root-ref/> <appender-ref ref="console"/> </errorhandler> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d{[hh:mm:ss:sss]|[mm-dd-yyyy]} [%c] %p - %m%n"/> </layout> <param name="maxfilesize" value="10mb"/> <param name="maxbackupindex" value="100"/> </appender> <logger name="ioreactorlog" additivity="false"> <level value="info"/> <appender-ref ref="default"/> </logger> <root> <level value="info"/> <appender-ref ref="default"/> <appender-ref ref="console"/> </root> </log4j:configuration>
is possible write of console out debug.txt?
use configuration file add debug.txt
target of fileappender
:
<appender name="fileappender" type="org.apache.log4j.fileappender"> <file value="debug.txt" /> <appendtofile value="true" /> <layout type="org.apache.log4j.patternlayout"> <conversionpattern value="%date [%thread] %-5level %logger [%property{ndc}] - %message%newline" /> </layout> </appender>
Comments
Post a Comment