使用Chainsaw将日志保存到文件中

时间:2015-10-16 08:54:12

标签: log4j log4cxx apache-chainsaw

我使用log4cxx实现了一个客户端记录器,我使用Chainsaw来监控来自客户端的日志。有没有像配置xml这样的方法来将日志保存到文件中

1 个答案:

答案 0 :(得分:0)

<?xml version="1.0" encoding="UTF-8"?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
  <plugin clas="org.apache.log4j.net.SocketReceiver" name="SocketReceiver-4560">
     <param name="active" value="true" />
     <param name="advertiseViaMulticastDNS" value="false"/>
     <param name="class" value="class org.apache.log4j.net.SocketReceiver"/>
     <param name="connectedSocketDetails" value="[]"/>
     <param name="name" value="SocketReceiver-4560"/>
     <param name="paused" value="false"/>
     <param name="port" value="4560"/>
     <param name="threshold" value="TRACE"/>
  </plugin>
  <appender name="MyNormalAppender" class="org.apache.log4j.FileAppender">
     <param name="file" value="NormalLogFile.log" />
     <param name="append" value="true" />
     <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d %5p %c{1} - %m%n" />
     </layout>
  </appender>
  <root>
     <priority value="all" />
     <appender-ref ref="SocketReceiver-4560" />
     <appender-ref ref="MyNormalAppender"/>
  </root>

我在网络设置的Receive事件中使用电锯保存配置功能,并添加MyNormalAppender。