Reputation: 10003
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.
Upvotes: 6
Views: 1728
Reputation: 7618
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>
Upvotes: 0