|
|
|||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.protomatter.syslog.BasicLogger | +--com.protomatter.syslog.UNIXSyslogLog
A logger that sends UDP packets to a UNIX syslog server. This logger sends UDP packets to UNIX servers running a BSD-style syslogd daemon. Refer to RFC 3164 for information about the protocol.
With the default formatting options, a call to Syslog.info(this, "Hello there") will result in the following to be written to /var/log/messages (or its equivalent) on the UNIX box:
Feb 10 16:02:21 sillysailor ProtomatterSyslog: [INFO] MyClass: Hello there |
This assumes you logged from a class called MyClass, that you havn't set the tag to some more meaningful value, and that your hostname is "sillysailor".
XML configuration class
Field Summary | |
static java.lang.String |
CALLER_TOKEN
|
static java.lang.String |
CHANNEL_TOKEN
|
static java.util.Map |
DEFAULT_SEVERITY_MAP
The default severity map. |
static java.lang.String |
FULLCALLER_TOKEN
|
static java.lang.String |
MESSAGE_TOKEN
|
static java.lang.String |
SEVERITY_TOKEN
|
static java.lang.String |
THREAD_TOKEN
|
static int |
UNIX_ALERT
Alert: take action immediately (RFC 3164). |
static int |
UNIX_CRITICAL
Critical: critical conitions (RFC 3164). |
static int |
UNIX_DEBUG
Debug: debug-level messages (RFC 3164). |
static int |
UNIX_EMERGENCY
Emergency: system is unusable (RFC 3164). |
static int |
UNIX_ERROR
Error: error conditions (RFC 3164). |
static int |
UNIX_INFO
Informational: informational messages (RFC 3164). |
static int |
UNIX_NOTICE
Notice: normal but significant (RFC 3164). |
static int |
UNIX_WARNING
Warning: warning conditions (RFC 3164). |
Fields inherited from class com.protomatter.syslog.BasicLogger |
formatter, policy, realPolicy |
Constructor Summary | |
UNIXSyslogLog()
Create a new UNIX logger with no settings. |
|
UNIXSyslogLog(java.net.InetAddress address)
Create a new UNIX logger sending messages to the given host on the default syslog port (514). |
|
UNIXSyslogLog(java.net.InetAddress address,
int port)
Create a new UNIX logger sending messages to the given host and port. |
Method Summary | |
void |
flush()
Flush the given logger's output. |
int |
getFacility()
Get the facility ID that messages appear to be from. |
java.net.InetAddress |
getLogServer()
Get the address of the log server. |
java.lang.String |
getMessageTemplate()
Get the text template used to format part of the packet body. |
int |
getPort()
Get the port number on the log server. |
java.util.Map |
getSeverityMap()
Get the map to use when converting Syslog severities into UNIX severities. |
protected java.lang.String |
getSeverityName(int syslogSeverity)
|
boolean |
getShowHostname()
Determine if we should show the hostname before the "tag". |
java.lang.String |
getTag()
Get the tag that messages appear as. |
void |
log(SyslogMessage message)
Log a message. |
void |
setFacility(int facility)
Set the facility ID that messages appear to be from. |
void |
setLogServer(java.net.InetAddress address)
Set the address of the log server. |
void |
setMessageTemplate(java.lang.String template)
Set the message body formatting template. |
void |
setPort(int port)
Set the port number on the log server. |
void |
setSeverityMap(java.util.Map map)
Set the map to use when converting Syslog severities into UNIX severities. |
void |
setShowHostname(boolean showHostname)
Set if we should show the hostname before the "tag". |
void |
setTag(java.lang.String tag)
Set the tag that messages appear as. |
void |
shutdown()
Shutdown this logger. |
Methods inherited from class com.protomatter.syslog.BasicLogger |
formatLogEntry, getName, getPolicy, getTextFormatter, isSuspended, mightLog, resetDateFormat, resume, setName, setPolicy, setTextFormatter, shouldLog, suspend |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String CHANNEL_TOKEN
public static final java.lang.String FULLCALLER_TOKEN
public static final java.lang.String CALLER_TOKEN
public static final java.lang.String MESSAGE_TOKEN
public static final java.lang.String THREAD_TOKEN
public static final java.lang.String SEVERITY_TOKEN
public static final int UNIX_DEBUG
public static final int UNIX_INFO
public static final int UNIX_NOTICE
public static final int UNIX_WARNING
public static final int UNIX_ERROR
public static final int UNIX_CRITICAL
public static final int UNIX_ALERT
public static final int UNIX_EMERGENCY
public static java.util.Map DEFAULT_SEVERITY_MAP
Constructor Detail |
public UNIXSyslogLog(java.net.InetAddress address, int port) throws SyslogInitException
public UNIXSyslogLog(java.net.InetAddress address) throws SyslogInitException
public UNIXSyslogLog() throws SyslogInitException
Method Detail |
public void setMessageTemplate(java.lang.String template)
{CHANNEL} | Channel name |
{CALLER-FULLNAME} | Full caller class name (with package) |
{CALLER} | Caller class name |
{MESSAGE} | Short message |
{THREAD} | Thread name |
{SEVERITY} | Severity ("DEBUG" ... "FATAL") |
The default value is "[{SEVERITY}] {CALLER}: {MESSAGE}". You can set this to something like "{CHANNEL}: {CALLER}: {MESSAGE}" or "{CALLER}: [{CHANNEL}] {MESSAGE}" as examples to see what you can do with this.
public java.lang.String getMessageTemplate()
public void setSeverityMap(java.util.Map map)
public java.util.Map getSeverityMap()
public java.lang.String getTag()
public void setTag(java.lang.String tag)
public boolean getShowHostname()
public void setShowHostname(boolean showHostname)
public void setFacility(int facility)
0 | kernel messages | |
1 | user-level messages | |
2 | mail system | |
3 | system daemons | |
4 | security/authorization messages (note 1) | |
5 | messages generated internally by syslogd | |
6 | line printer subsystem | |
7 | network news subsystem | |
8 | UUCP subsystem | |
9 | clock daemon (note 2) | |
10 | security/authorization messages (note 1) | |
11 | FTP daemon | |
12 | NTP subsystem | |
13 | log audit (note 1) | |
14 | log alert (note 1) | |
15 | clock daemon (note 2) | |
16 | local use 0 (local0) | |
17 | local use 1 (local1) | |
18 | local use 2 (local2) | |
19 | local use 3 (local3) | |
20 | local use 4 (local4) | |
21 | local use 5 (local5) | |
22 | local use 6 (local6) | |
23 | local use 7 (local7) |
Note 1: Various operating systems have been found to utilize Facilities 4, 10, 13 and 14 for security/authorization, audit, and alert messages which seem to be similar.
Note 2: Various operating systems have been found to utilize both Facilities 9 and 15 for clock (cron/at) messages.
The default is 16 (Local Use 0).
public int getFacility()
public void setLogServer(java.net.InetAddress address)
public java.net.InetAddress getLogServer()
public void setPort(int port)
public int getPort()
public final void log(SyslogMessage message)
protected java.lang.String getSeverityName(int syslogSeverity)
public void shutdown()
Syslogger
public void flush()
Syslogger
|
Protomatter Software v1.1.8 Copyright 1998-2002 Nate Sammons |
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Protomatter Software v1.1.8 | http://protomatter.sourceforge.net/1.1.8 |