log4net和chainsaw培训资料
参考链接:
l 官方首页:http://logging.apache.org/log4net/
l 配置:://logging.apache.org/log.net/release/config-examples.html
l 关于日志格式的详细说明:http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html
关于log4net和chainsaw:
利用UDPAppender发送给Chainsaw来做日志实时分析
://logging.apache.org/log4net/release/howto/chainsaw.html
UDPAppender的中文问题:
://blog.csdn.net/omiao/archive/2010/05/26/5626179.aspx
“发现问题出现在log4net项目log4net.Util.Transform类,该类里面定义一个正则表达式:
private static Regex INVALIDCHARS=new Regex(@"[^\x09\x0A\x0D\x20-\xFF\u00FF-\u07FF\uE000-\uFFFD]",RegexOptions.Compiled);
把所有的中文字符都给过滤了,修改为:
private static Regex INVALIDCHARS = new Regex(@"[^\x09\x0A\x0D\x20-\xFF\u00FF-\uFFFD]", RegexOptions.Compiled);”
· App中配置,红色部门是不能修改的。Log4net-->log4j的格式转化
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
<remoteAddress value="127.0.0.1" />
<remotePort value="8080" />
<layout type="log4net.Layout.XmlLayoutSchemaLog4j">
<locationInfo value="true" />
</layout>
</appender>
· Chainsaw用的log4j的配置
<?xml version="1.0" encoding="UTF-8" ?>
<!--<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
<plugin name="UDPReceiver" class="org.apache.log4j.net.UDPReceiver">
<param name="Port" value="8080" />
</plugin>
</log4j:configuration>
· 运行效果截图