Class LogFileXMLReceiver
- All Implemented Interfaces:
Plugin, Component, Thresholdable, org.apache.log4j.spi.OptionHandler
This receiver supports log files created using log4j's XMLLayout, as well as java.util.logging XMLFormatter (via the org.apache.log4j.spi.Decoder interface).
By default, log4j's XMLLayout is supported (no need to specify a decoder in that case).
To configure this receiver to support java.util.logging's XMLFormatter, specify a 'decoder' param of org.apache.log4j.xml.UtilLoggingXMLDecoder.
Tailing -may- work, but not in all cases (try using a file:// URL). If a process has a log file open, the receiver may be able to read and tail the file. If the process closes the file and reopens the file, the receiver may not be able to continue tailing the file.
An expressionFilter may be specified. Only events passing the expression will be forwarded to the log4j framework.
Once the event has been "posted", it will be handled by the appenders currently configured in the LoggerRespository.
- Since:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate Decoderprivate Ruleprivate static final Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Readerprivate booleanprivate booleanFields inherited from class Receiver
thresholdLevelFields inherited from class PluginSkeleton
active, nameFields inherited from class ComponentBase
repository -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidProcess the fileAccessorAccessorAccessorbooleanAccessorfinal booleanWhen true, this property uses the current Thread to perform the import, otherwise when false (the default), a new Thread is created and started to manage the import.static voidprivate booleanpassesExpression(org.apache.log4j.spi.LoggingEvent event) private voidprivate voidvoidsetDecoder(String _decoder) Specify the class name implementing org.apache.log4j.spi.Decoder that can process the file.voidsetFileURL(String fileURL) Specify the URL of the XML-formatted file to process.voidsetFilterExpression(String filterExpression) Set the filter expression that will cause only events which pass the filter to be forwarded to the log4j framework.voidsetTailing(boolean tailing) Set the 'tailing' flag - may only work on file:// URLs and may stop tailing if the writing process closes the file and reopens.final voidsetUseCurrentThread(boolean useCurrentThread) Sets whether the current Thread or a new Thread is created to perform the import, the default being false (new Thread created).voidshutdown()Close the receiver, release any resources that are accessing the file.Methods inherited from class Receiver
doPost, getThreshold, isAsSevereAsThreshold, setThresholdMethods inherited from class PluginSkeleton
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getLoggerRepository, getName, isActive, isEquivalent, removePropertyChangeListener, removePropertyChangeListener, setLoggerRepository, setNameMethods inherited from class ComponentBase
getLogger, getNonFloodingLogger, resetErrorCount
-
Field Details
-
fileURL
-
expressionRule
-
filterExpression
-
decoder
-
tailing
private boolean tailing -
decoderInstance
-
reader
-
FILE_KEY
- See Also:
-
host
-
path
-
useCurrentThread
private boolean useCurrentThread
-
-
Constructor Details
-
LogFileXMLReceiver
public LogFileXMLReceiver()
-
-
Method Details
-
getFileURL
-
setFileURL
Specify the URL of the XML-formatted file to process.- Parameters:
fileURL-
-
getDecoder
-
setDecoder
Specify the class name implementing org.apache.log4j.spi.Decoder that can process the file.- Parameters:
_decoder-
-
getFilterExpression
-
isTailing
public boolean isTailing()Accessor- Returns:
- tailing flag
-
setTailing
public void setTailing(boolean tailing) Set the 'tailing' flag - may only work on file:// URLs and may stop tailing if the writing process closes the file and reopens.- Parameters:
tailing-
-
setFilterExpression
Set the filter expression that will cause only events which pass the filter to be forwarded to the log4j framework.- Parameters:
filterExpression-
-
passesExpression
private boolean passesExpression(org.apache.log4j.spi.LoggingEvent event) -
main
-
shutdown
public void shutdown()Close the receiver, release any resources that are accessing the file. -
activateOptions
public void activateOptions()Process the file -
process
- Throws:
IOException
-
processEvents
-
isUseCurrentThread
public final boolean isUseCurrentThread()When true, this property uses the current Thread to perform the import, otherwise when false (the default), a new Thread is created and started to manage the import.- Returns:
- true, if the current thread is used
-
setUseCurrentThread
public final void setUseCurrentThread(boolean useCurrentThread) Sets whether the current Thread or a new Thread is created to perform the import, the default being false (new Thread created).- Parameters:
useCurrentThread-
-