apache chainsaw v2 gets: bind exception or connection lost! :: invalid stream header: 3c3f786d

守給你的承諾、 提交于 2019-12-12 03:25:32

问题


i wrote a log server that eats the stuff coming from a bunch of sockethandlers on other devices and writes it to a log file which looks like:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
  <date>2016-05-15T06:40:03</date>
  ...
</record>
...

i am new to chainsaw.

chainsaw can open these files using: load java util file.

if i add a simple receiver for port 4445, i get a bind exception.

if i add a simple receiver for port 4560, i get the connection lost.

i do not have any config files and am unsure about how to write one.

if i can get the simple receiver to work, can chainsaw rollover the log files and separate the log files by the device they are coming from?

thanks

edit 1: looks like that reveiver may use: org.apache.log4j.xml.XMLDecoder, which may not be the correct one. this post suggests: org.apache.log4j.xml.UtilLoggingXMLDecoder. manually trying this does not seem to work.

edit 2: thanks to scott deboy on the log4j mailing list, this config file worked:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
<plugin name="XMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
      <param name="decoder" value="org.apache.log4j.xml.UtilLoggingXMLDecoder"/>
      <param name="Port" value="2222"/>
   </plugin>
<root>
  <priority value="debug"/>
</root>
</log4j:configuration>

edit 3: added a rollover:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
<plugin name="XMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
      <param name="decoder" value="org.apache.log4j.xml.UtilLoggingXMLDecoder"/>
      <param name="Port" value="2222"/>
   </plugin>
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
      <param name="Threshold" value="INFO" />
      <param name="File" value="sample.log"/>
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d %-5p  [%c{1}] %m %n" />
      </layout>
   </appender>
<root>
  <priority value="debug"/>
  <appender-ref ref="fileAppender" /> 
</root>
</log4j:configuration>

this seems to work, but all of the chainsaw logging (as well as my stuff) is in the log file.


回答1:


Chainsaw can parse log files matching the log4j xml format, or regular text log files with a consistent log format via VFSLogFilePatternReceiver, but not your own xml format.



来源:https://stackoverflow.com/questions/37239400/apache-chainsaw-v2-gets-bind-exception-or-connection-lost-invalid-stream-he

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!