Syslog White Paper FAQ Examples JavaDoc Classloader
Protomatter Software v1.1.7

com.protomatter.syslog
Class SyslogHandler

com.protomatter.syslog.SyslogHandler

public class 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.

Here's a usage example:

If you have syslog configured to show the channel name and log all message levels, you'll see something like this:

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:


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

SyslogHandler

public SyslogHandler()
Create a new handler for routing messages to Syslog.
Method Detail

resetLevelMap

public void resetLevelMap()
Reset the level conversion map to the default. The default map is:

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


close

public void close()
Close the handler.

flush

public void flush()
Flush this handler. This method simply calls Syslog.flush().
See Also:
Syslog.flush()

publish

public void publish(com.protomatter.syslog.LogRecord record)
Route the given log record into Syslog. If this handler has been closed, the record is ignored. If a filter has been set, then it is applied to record to see if it should be passed on to Syslog.

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.


getLevelMap

public java.util.Map getLevelMap()
Get the conversion map for levels. The key in the map is an instance of java.util.logging.Level and the value is a java.lang.Integer which is a wrapper for Syslog.DEBUG, Syslog.INFO, etc.

setLevelMap

public void setLevelMap(java.util.Map levelMap)
Set the conversion map for levels. The key in the map is an instance of java.util.logging.Level and the value is a java.lang.Integer which is a wrapper for Syslog.DEBUG, Syslog.INFO, etc.

Protomatter Software v1.1.7
Copyright 1998-2002 Nate Sammons

Protomatter Software v1.1.7 http://protomatter.sourceforge.net/1.1.7