How to start using Chainsaw for Log4j?

烂漫一生 提交于 2019-12-10 04:35:44

问题


I'd like to start using Chainsaw v2. There is almost no information about it. I've found only this , but links cannot be opened, so it isn't clear.

I use socketAppender:

log4j.rootLogger=DEBUG, server

log4j.appender.server=org.apache.log4j.net.SocketAppender
log4j.appender.server.Port=4712
log4j.appender.server.RemoteHost=localhost
log4j.appender.server.ReconnectionDelay=10000

I created file log4j.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
   <appender name="A2" class="org.apache.log4j.ConsoleAppender">
      <layout class="org.apache.log4j.SimpleLayout"/>
   </appender>

   <plugin name="SocketReceiver" class="org.apache.log4j.net.SocketReceiver">
      <param name="Port" value="4712"/>
   </plugin>

   <root>
      <level value="debug"/>
   </root>
</log4j:configuration>

And selected it in let me search for configuration file. But there are no logs. What should I do next?


回答1:


I'm one of the Chainsaw authors. Try the latest developer snapshot of Chainsaw, which will be released soon. It has a new configuration UI which should make it much easier to configure, particularly if all you're doing is using a socket appender.

There are a ton of new features in this version. Feel free to email with questions or post to the log4j-user mailing list.

Developer snapshot available here: http://people.apache.org/~sdeboy

Scott




回答2:


Please use only one file log4j.properties or log4j.xml.And check this article for Chainsaw. It may be helpful to you.

This is sample log4j.properties file for Chainsaw,

  log4j.rootCategory=DEBUG, zeroconf, chainsaw
  # Socket Appender
  log4j.appender.chainsaw=org.apache.log4j.net.SocketAppender
  log4j.appender.chainsaw.remoteHost=localhost
  log4j.appender.chainsaw.port=4445
  log4j.appender.chainsaw.locationInfo=true



回答3:


start server first means in chainsaw log server receiver you can select first socket receiver.

log4j.rootLogger=DEBUG, CHAINSAW_CLIENT

log4j.appender.CHAINSAW_CLIENT=org.apache.log4j.net.SocketAppender log4j.appender.CHAINSAW_CLIENT.RemoteHost=localhost log4j.appender.CHAINSAW_CLIENT.Port=4445
log4j.appender.CHAINSAW_CLIENT.LocationInfo=true



来源:https://stackoverflow.com/questions/11790920/how-to-start-using-chainsaw-for-log4j

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