|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.protomatter.syslog.SyslogHandler
A JDK 1.4 logging system handler to route messages into Syslog. Logger names are converted to syslog channel names.
The following log properties file assigns the SyslogHandler class as the only log handler.
.level = ALL handlers = com.protomatter.syslog.SyslogHandler |
Here's a usage example:
import java.util.logging.Logger; ... // Make a new logger Logger myLogger = Logger.getLogger("foo.bar"); // Write some log messages myLogger.info("Info message to my logger"); myLogger.warning("Warning message to my logger"); myLogger.severe("Severe message to my logger"); |
If you have syslog configured to show the channel name and log all message levels, you'll see something like this:
11/01/2001 20:09:16 [INFO] [foo.bar ] Test.main():23 Info message to my logger 11/01/2001 20:09:16 [WARN] [foo.bar ] Test.main():25 Warning message to my logger 11/01/2001 20:09:16 [EROR] [foo.bar ] Test.main():27 Severe message to my logger |
If the "SyslogHandler.xml" system property is set, this class will call SyslogXML.configure() with that configuration file.
So, to configure syslog and use the JDK 1.4 logging API to write to it, do the following:
java \ ... -DSyslogHandler.xml=/path/to/syslog.xml \ -Djava.util.logging.config.file=/path/to/logging.properties \ ... java-main-class |
Constructor Summary | |
SyslogHandler()
Create a new handler for routing messages to Syslog. |
Method Summary | |
void |
close()
Close the handler. |
void |
flush()
Flush this handler. |
java.util.Map |
getLevelMap()
Get the conversion map for levels. |
void |
publish(com.protomatter.syslog.LogRecord record)
Route the given log record into Syslog. |
void |
resetLevelMap()
Reset the level conversion map to the default. |
void |
setLevelMap(java.util.Map levelMap)
Set the conversion map for levels. |
Constructor Detail |
public SyslogHandler()
Method Detail |
public void resetLevelMap()
java.util.logging.Level | Syslog Level |
---|---|
Level.SEVERE | Syslog.ERROR |
Level.WARNING | Syslog.WARNING |
Level.INFO | Syslog.INFO |
Level.CONFIG | Syslog.DEBUG |
Level.FINE | Syslog.DEBUG |
Level.FINER | Syslog.DEBUG |
Level.FINEST | Syslog.DEBUG |
public void close()
public void flush()
Syslog.flush()
public void publish(com.protomatter.syslog.LogRecord record)
If a formatter has been set, it is used to format the message. If it has not been set, then the record's message is used as-is.
If a throwable has been set, it is used as the message detail when the record is sent to Syslog.
The log level is converted from a java.util.logging.Level according to the level map for this handler.
The name of the java.util.logging.Logger is used as the channel name.
Once these conversions have been made, the information is passed onto Syslog for further processing.
public java.util.Map getLevelMap()
public void setLevelMap(java.util.Map levelMap)
|
Protomatter Classes v1.1.6 Copyright 1998-2001 Nate Sammons |
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Protomatter Classes v1.1.6 | http://protomatter.sourceforge.net/1.1.6 |