Log4j2 Syslog appender(TCP协议)在多行中发送异常堆栈跟踪并显示错误的日志级别

时间:2015-01-22 19:20:43

标签: log4j2 syslog

我正在使用log4j2和syslog appender。我使用TCP作为协议。和Kiwi系统日志服务器。在发送错误消息时,异常堆栈跟踪通过TCP在多行中发送,每行包含在一个数据包中。堆栈跟踪的第一行是在Kiwi系统日志服务器中调整正确的日志级别,但是相同的堆栈跟踪的后续行为是错误的日志级别和设施。在UDP协议的情况下不会发生这种情况。

01-22-2015  10:25:40    Local0.Error    10.74.224.251   1 2015-01-23T00:20:11.473+05:30 ABC-PC - - [mdc@1000 category="com.test.dataSender" exception="" thread="ForkJoinPool-57-worker-1"] [8ef587c9-5605-42d3-88ff-0d865cf6e510]: Failed to add management service instance 'aa', Cause: aa
01-22-2015  10:25:39    Local7.Debug    10.74.224.251   " thread="ForkJoinPool-57-worker-1"] [8ef587c9-5605-42d3-88ff-0d865cf6e510]:  Unknown Host : aa
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:398)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.util.concurrent.ForkJoinPool.work(ForkJoinPool.java:646)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:784)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.util.concurrent.ForkJoinWorkerThread.execTask(ForkJoinWorkerThread.java:604)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:334)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.util.concurrent.RecursiveTask.exec(RecursiveTask.java:93)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at com.test.data.core.mapreduce.MapReduceTask.compute(MapReduceTask.java:26)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at com.test.data.core.datasource.DatasourceAdder.map(DatasourceAdder.java:21)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at com.test.data.core.datasource.DatasourceAdder.map(DatasourceAdder.java:70)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at com.test.data.um.datasource.UMDatasourceService.addDatasources(UMDatasourceService.java:58)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at com.test.data.um.datasource.UMDatasourceServiceFacadeImpl.addDatasources(UMDatasourceServiceFacadeImpl.java:211)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at com.test.data.um.datasource.UMDatasourceServiceFacadeImpl.discoverDatasources(UMDatasourceServiceFacadeImpl.java:248)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.net.InetAddress.getByName(InetAddress.java:1048)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.net.InetAddress.getAllByName(InetAddress.java:1098)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.net.InetAddress.getAllByName(InetAddress.java:1162)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.net.InetAddress.getAllByName0(InetAddress.java:1246)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
01-22-2015  10:25:39    Local7.Debug    10.74.224.251      at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
01-22-2015  10:25:39    Local0.Error    10.74.224.251   1 2015-01-23T00:20:11.471+05:30 ABC-PC [OnCommand API Services] - - [mdc@1000 category="com.test.data.um.datasource.UMDatasourceServiceFacadeImpl" exception="java.net.UnknownHostException: aa

关于[mdc@1000的另一个问题是什么?为什么要印刷。我在log4j2配置文件中添加了includeMDC=true

<Syslog name="syslogAppender" 
        host="${sys:syslog.host}" port="${sys:syslog.port}" protocol="${sys:syslog.protocol}" 
        appName="${serviceName}" enabled="${sys:syslog.enabled}" format="RFC5424" 
        newLine="true" includeMDC="true" mdcId="mdc" ignoreExceptions="true" 
        enterpriseNumber="1000">
   <LoggerFields>
      <KeyValuePair key="thread" value="%t" />
      <KeyValuePair key="category" value="%c" />
      <KeyValuePair key="exception" value="%ex{full}" />
   </LoggerFields>
</Syslog>

0 个答案:

没有答案