org.jalore.log4j
Class Log4JFileReader

java.lang.Object
  extended by org.jalore.log4j.Log4JFileReader
All Implemented Interfaces:
LogReader

public class Log4JFileReader
extends java.lang.Object
implements LogReader

Implementation of LogReader using a log4j file.

This reader sets the property Log4JProperties.FILE_NAME with the log file name in each log message found. It is useful to have a track of the origin of each message when using MultiLogReader.

Author:
Nicolas Dutertry

Constructor Summary
Log4JFileReader(java.io.File logFile, java.lang.String log4jPattern)
          Constructs a Log4JFileReader.
 
Method Summary
 java.util.Set<java.lang.String> getPropertyNames()
          Returns the list of property names that will be available in read log messages.
 boolean hasMoreMessages()
          Tests if this reader contains more log messages.
 LogMessage nextMessage()
          Returns the next log message of this reader or null if no more message is available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log4JFileReader

public Log4JFileReader(java.io.File logFile,
                       java.lang.String log4jPattern)
                throws java.io.IOException
Constructs a Log4JFileReader.

The given pattern is a log4j type pattern. It must only describe the first line of log messages or the beginning of this line.

Parameters:
logFile - the log file
log4jPattern - log4j type pattern describing first line of messages
Throws:
java.io.IOException - if an error occurred while reading the log file
Method Detail

hasMoreMessages

public boolean hasMoreMessages()
Description copied from interface: LogReader
Tests if this reader contains more log messages.

Specified by:
hasMoreMessages in interface LogReader
Returns:
true if and only if this reader contains at least one more log message to provide; false otherwise.

nextMessage

public LogMessage nextMessage()
                       throws java.io.IOException
Description copied from interface: LogReader
Returns the next log message of this reader or null if no more message is available.

Specified by:
nextMessage in interface LogReader
Returns:
the next log message
Throws:
java.io.IOException - if an error occurred while reading the next message

getPropertyNames

public java.util.Set<java.lang.String> getPropertyNames()
Returns the list of property names that will be available in read log messages. This list is computed from the log4j pattern used to build this log reader and also contains the value Log4JProperties.FILE_NAME.

Returns:
list of property names available in log messages


Copyright © 2009 Nicolas Dutertry. All Rights Reserved.