|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.java.io.LogWriter
A LogWriter
allows an application to incapsulate an output
stream and dumps its logs on it.
To control the different kinds of log messages they are separated into channels that can be activated setting to true the right property.
The configurations that control this writer are:
Inner Class Summary | |
protected class |
LogWriter.Agent
Class implementing the background logging. |
Field Summary | |
boolean |
active
Tells if this log is active |
static java.lang.String |
CH_EXCEPTION_TRACING
String identifier for the exception tracing channel. |
static java.lang.String |
CH_QUEUE_STATUS
|
Configurations |
configurations
Configuration parameters. |
static java.lang.String |
DEFAULT_DATEFORMAT
This string control the standard date format used used for log timestamping. |
static java.lang.String |
DEFAULT_IDENTIFIER
This string identifies this log writer and its used to differentiate between configurations. |
private java.text.SimpleDateFormat |
formatter
The timestamp formatter. |
private java.lang.String |
identifier
This string identifies this log writer and its used to discriminate between configuration parameters. |
static java.lang.String |
KEYWORD_CHANNEL
|
static java.lang.String |
KEYWORD_DATEFORMAT
|
static java.lang.String |
KEYWORD_FILE
|
static java.lang.String |
KEYWORD_QUEUE_MAXAGE
|
static java.lang.String |
KEYWORD_QUEUE_MAXSIZE
|
static java.lang.String |
KEYWORD_TIMESTAMP
|
private boolean |
logChannel
Tells if the log message should contain a channel. |
private LogWriter.Agent |
logDaemon
Background logger thread. |
protected SimpleQueue |
logQueue
Log message queue. |
private long |
queue_maxage
Maximum age of a queued log record, in milliseconds. |
private long |
queue_maxsize
Maximum size of a log queue. |
private boolean |
timestamp
Tells if the log message should be started by a time stamp. |
private java.io.PrintWriter |
writer
The writer encapsulated. |
Constructor Summary | |
LogWriter(Configurations configurations)
Constructs this class and gets output file from configurations. |
|
LogWriter(java.io.OutputStream output,
Configurations configurations)
Constructs this class with the output stream to encapsulate using default identifier. |
|
LogWriter(java.io.OutputStream output,
java.lang.String identifier,
Configurations configurations)
Constructs this class with the output stream to encapsulate. |
|
LogWriter(java.lang.String identifier,
Configurations configurations)
Constructs this class using identifier to discriminate between configuration parameters and gets output file from configurations. |
|
LogWriter(java.io.Writer output,
Configurations configurations)
Constructs this class with the output writer to encapsulate using default identifier. |
|
LogWriter(java.io.Writer output,
java.lang.String identifier,
Configurations configurations)
Constructs this class with the output writer to encapsulate. |
Method Summary | |
void |
flush()
Flush the log. |
boolean |
isActive()
Tells if it is active. |
boolean |
isActive(java.lang.String channel)
Tells if the given channel is active. |
void |
log(java.lang.String channel,
java.lang.String message)
Prints the log message on the right channel. |
void |
log(java.lang.String channel,
java.lang.Throwable t)
Prints the error message and stack trace if channel enabled. |
void |
log(java.lang.Throwable t)
Deprecated. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final java.lang.String DEFAULT_IDENTIFIER
public static final java.lang.String DEFAULT_DATEFORMAT
public static final java.lang.String KEYWORD_DATEFORMAT
public static final java.lang.String KEYWORD_TIMESTAMP
public static final java.lang.String KEYWORD_CHANNEL
public static final java.lang.String KEYWORD_FILE
public static final java.lang.String KEYWORD_QUEUE_MAXAGE
public static final java.lang.String KEYWORD_QUEUE_MAXSIZE
public static final java.lang.String CH_QUEUE_STATUS
public static final java.lang.String CH_EXCEPTION_TRACING
public Configurations configurations
public boolean active
private long queue_maxage
When the log daemon detects the record older than this, it flushes the queue, just to make the observer happy, even if that is a single message in the queue.
Default is hardcoded to 5000 ms.
private long queue_maxsize
When one of the log(...)
messages detects that the log
queue size is more than this variable permits, it flushes the queue,
to keep the memory clean.
Default is 1000.
private java.lang.String identifier
private boolean timestamp
private java.text.SimpleDateFormat formatter
private java.io.PrintWriter writer
private LogWriter.Agent logDaemon
private boolean logChannel
protected SimpleQueue logQueue
Constructor Detail |
public LogWriter(Configurations configurations) throws java.io.IOException
configurations
- the configurations needed at initialization.public LogWriter(java.lang.String identifier, Configurations configurations) throws java.io.IOException
identifier
- the identifier for this log writer.configurations
- the configurations needed at initialization.public LogWriter(java.io.Writer output, Configurations configurations) throws java.io.IOException
output
- the output writer to encapsulate.configurations
- the configurations needed at initialization.public LogWriter(java.io.OutputStream output, Configurations configurations) throws java.io.IOException
output
- the output stream to encapsulate.configurations
- the configurations needed at initialization.public LogWriter(java.io.OutputStream output, java.lang.String identifier, Configurations configurations) throws java.io.IOException
output
- the output stream to encapsulate.identifier
- the identifier for this log writer.configurations
- the configurations needed at initialization.public LogWriter(java.io.Writer output, java.lang.String identifier, Configurations configurations) throws java.io.IOException
output
- the output writer to encapsulate.identifier
- the identifier for this log writer.configurations
- the configurations needed at initialization.Method Detail |
public boolean isActive()
public boolean isActive(java.lang.String channel)
public void log(java.lang.String channel, java.lang.String message)
A "channel" is a virtual log that may be enabled or disabled by setting the property "identifier".channel.???=true where ??? is the channel identifier that must be passed with the message. If a channel is not recognized or its property is set to false the message is not written.
public void log(java.lang.String channel, java.lang.Throwable t)
public void log(java.lang.Throwable t)
public void flush()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |