how to configure apache chainsaw for input from multiple devices
Asked Answered
S

1

6

I am new to chainsaw and log4j, this is a followup to a previous post. i have some devices that use socket handlers to send records to jigsaw using the following config file:

<?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="chainsawtablet.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>

The receiver seems to work in that I see a tab in the chainsaw gui with some log records. but it never seems to write a log file. maybe it's waiting for a day to go by or something. is there a way to make it rollover more often?

No records are showing up in the log file. do I need some xml to hook the receiver up to an appender or is it automatic?

I would like the log files separated by their source host. Also, if the connection is restarted, i would like the log file to rollover.

I would also like to keep a weeks worth of log files.

I would like to see all of the log records, so should: param name="Threshold" value="INFO" be ALL instead of INFO?

How about the: priority value="debug"?

Any pointers will be appreciated.

edit: trying a: datePattern value="yyyyMMdd-HHmm" which supposedly rolls over every minute does not generate any log file either.

edit related question and post, also here and there.

Snailfish answered 21/5, 2016 at 5:41 Comment(0)
P
0

You don't appear to have log4j hooked-up to Chainsaw. The log messages you are seeing in the Chainsaw GUI - do they looks like internal Chainsaw self-logging messages?

You need to configure a SocketAppender and link it to at least one logger, or the root logger. Events from your application will then appear in Chainsaw. If you want to log-out to a log file that is a different matter, but I'm assuming that you want to use Chainsaw as a live-event-display GUI, since that is what most folks use it for.

Here's a minimal config file:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug='true'>

  <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %5p %c - %m%n"/>
    </layout>
  </appender>

  <appender name="CHAINSAW" class="org.apache.log4j.net.SocketAppender">
    <param name="RemoteHost" value="localhost"/>
    <param name="Port" value="4445"/>
    <param name="LocationInfo" value="true"/>
  </appender>

  <root>
    <level value ="debug"/>
    <appender-ref ref="STDOUT" />
    <appender-ref ref="CHAINSAW" />
  </root>

</log4j:configuration>
Pippy answered 7/6, 2016 at 7:24 Comment(4)
i am not using log4j. the messages i see are from the xml socket reciever - they look like normal xml jdk logging records.Snailfish
are you saying that i need an appender for each receiver?Snailfish
I'm struggling to follow what you are trying to set-up. You mention i am new to chainsaw and log4j but then i am not using log4j. What is jigsaw? What are you trying to do with Chainsaw - have a GUI with which to monitor logging-events live? Are you able to configure your application doing the logging? Is it running the log4j API and logging to a remote socket?Pippy
android tablets use jdk util logging and socket handler to send to chainsaw xml socket receiver. sorry, jigsaw is a typo, will edit. i would like to use chainsaw to view in real time and write to a rolling log file. ideally each tablet would get it's own tab in chainsaw and it's own rolling file. currently i can view the logs in real time (for a while anyway), but no files get written.Snailfish

© 2022 - 2024 — McMap. All rights reserved.