views:

217

answers:

1

We have customized appender (com.mycompany.log4j.XAppender) with customized layout (com.mycompany.log4j.XPatternLayout). While ChainSaw opens the log file, it keeps complaining: found non-matching line: . How to fix that?

+1  A: 

You mention Chainsaw is opening the log file, but it's not clear how.

You can open an xmllayout-formatted log file using the file-open menu in Chainsaw.

You can load a regular text log file in chainsaw by configuring Chainsaw to use a LogFilePatternReceiver, which can parse & tail the log file (LogFilePatternReceiver allows you to define the pattern in your log file, and will then parse and tail the log file).

An example receiver configuration is available from Chainsaw's Welcome tab, and LogFilePatternReceiver javadoc is available from Chainsaw's help menu.

If you have a custom xml format, you need to either create your own XmlDecoder implementation that will convert your xml to logging events (and configure Chainsaw to use an xml-based receiver with your decoder), or you can pre-process your xml file and output a file conforming to log4j's dtd.

The 'found non-matching line' message above looks like it is an xmllayout-based format. If you're having problems loading a log file that conforms to log4j's dtd, I'd suggest posting an example chunk of your log file with a question to the log4j-dev mailing list.

Scott
My log4j.config is: <appender name="LOG_FILE" class="com.mycompany.log4j.XDailyRollingFileAppender"> <param name="DatePattern" value="'.'yyyy-MM-dd"/><param name="file" value="log.xml"/><param name="append" value="true" /> <layout class="com.mycompany.log4j.XXMLLayout"><param name="DateFormat" value="MM-dd-yyyy HH:mm:ss.S"/> </layout> <filter class="org.apache.log4j.varia.LevelRangeFilter"> <param name="LevelMin" value="DEBUG#com.mycompany.log4j.XPriority" /> <param name="LevelMax" value="FATAL#com.mycompany.log4j.XPriority" /> </filter> </appender>
PerlDev