Package org.apache.log4j.net
Class SyslogAppender
java.lang.Object
org.apache.log4j.AppenderSkeleton
org.apache.log4j.net.SyslogAppender
- All Implemented Interfaces:
Appender
,OptionHandler
Use SyslogAppender to send log messages to a remote syslog daemon.
- Author:
- Ceki Gülcü, Anders Kristensen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
static final int
security/authorization messagesstatic final int
security/authorization messages (private)static final int
clock daemonstatic final int
System daemonsstatic final int
ftp daemonstatic final int
Kernel messagesstatic final int
reserved for local usestatic final int
reserved for local usestatic final int
reserved for local usestatic final int
reserved for local usestatic final int
reserved for local usestatic final int
reserved for local usestatic final int
reserved for local usestatic final int
reserved for local usestatic final int
line printer subsystemstatic final int
Mail systemstatic final int
network news subsystemstatic final int
messages generated internally by syslogdstatic final int
Random user-level messagesstatic final int
UUCP subsystemprotected static final int
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
-
Constructor Summary
ConstructorsConstructorDescriptionSyslogAppender
(Layout layout, int syslogFacility) SyslogAppender
(Layout layout, String syslogHost, int syslogFacility) -
Method Summary
Modifier and TypeMethodDescriptionvoid
This method returns immediately as options are activated when they are set.void
append
(LoggingEvent event) Subclasses ofAppenderSkeleton
should implement this method to perform actual logging.void
close()
Release any resources held by this SyslogAppender.Returns the value of the Facility option.static int
getFacility
(String facilityName) Returns the integer value corresponding to the named syslog facility, or -1 if it couldn't be recognized.boolean
Returns the value of the FacilityPrinting option.static String
getFacilityString
(int syslogFacility) Returns the specified syslog facility as a lower-case String, e.g.final boolean
If true, the appender will generate the HEADER part (that is, timestamp and host name) of the syslog packet.Returns the value of the SyslogHost option.boolean
The SyslogAppender requires a layout.void
setFacility
(String facilityName) Set the syslog facility.void
setFacilityPrinting
(boolean on) If the FacilityPrinting option is set to true, the printed message will include the facility name of the application.final void
setHeader
(boolean val) Returns whether the appender produces the HEADER part (that is, timestamp and host name) of the syslog packet.void
setSyslogHost
(String syslogHost) The SyslogHost option is the name of the the syslog host where log output should go.Methods inherited from class org.apache.log4j.AppenderSkeleton
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
-
Field Details
-
LOG_KERN
public static final int LOG_KERNKernel messages- See Also:
-
LOG_USER
public static final int LOG_USERRandom user-level messages- See Also:
-
LOG_MAIL
public static final int LOG_MAILMail system- See Also:
-
LOG_DAEMON
public static final int LOG_DAEMONSystem daemons- See Also:
-
LOG_AUTH
public static final int LOG_AUTHsecurity/authorization messages- See Also:
-
LOG_SYSLOG
public static final int LOG_SYSLOGmessages generated internally by syslogd- See Also:
-
LOG_LPR
public static final int LOG_LPRline printer subsystem- See Also:
-
LOG_NEWS
public static final int LOG_NEWSnetwork news subsystem- See Also:
-
LOG_UUCP
public static final int LOG_UUCPUUCP subsystem- See Also:
-
LOG_CRON
public static final int LOG_CRONclock daemon- See Also:
-
LOG_AUTHPRIV
public static final int LOG_AUTHPRIVsecurity/authorization messages (private)- See Also:
-
LOG_FTP
public static final int LOG_FTPftp daemon- See Also:
-
LOG_LOCAL0
public static final int LOG_LOCAL0reserved for local use- See Also:
-
LOG_LOCAL1
public static final int LOG_LOCAL1reserved for local use- See Also:
-
LOG_LOCAL2
public static final int LOG_LOCAL2reserved for local use- See Also:
-
LOG_LOCAL3
public static final int LOG_LOCAL3reserved for local use- See Also:
-
LOG_LOCAL4
public static final int LOG_LOCAL4reserved for local use- See Also:
-
LOG_LOCAL5
public static final int LOG_LOCAL5reserved for local use- See Also:
-
LOG_LOCAL6
public static final int LOG_LOCAL6reserved for local use- See Also:
-
LOG_LOCAL7
public static final int LOG_LOCAL7reserved for local use- See Also:
-
SYSLOG_HOST_OI
protected static final int SYSLOG_HOST_OI- See Also:
-
FACILITY_OI
protected static final int FACILITY_OI- See Also:
-
-
Constructor Details
-
SyslogAppender
public SyslogAppender() -
SyslogAppender
-
SyslogAppender
-
-
Method Details
-
close
public void close()Release any resources held by this SyslogAppender.- Since:
- 0.8.4
-
getFacilityString
Returns the specified syslog facility as a lower-case String, e.g. "kern", "user", etc. -
getFacility
Returns the integer value corresponding to the named syslog facility, or -1 if it couldn't be recognized.- Parameters:
facilityName
- one of the strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. The matching is case-insensitive.- Since:
- 1.1
-
append
Description copied from class:AppenderSkeleton
Subclasses ofAppenderSkeleton
should implement this method to perform actual logging. See alsoAppenderSkeleton.doAppend
method.- Specified by:
append
in classAppenderSkeleton
-
activateOptions
public void activateOptions()This method returns immediately as options are activated when they are set.- Specified by:
activateOptions
in interfaceOptionHandler
- Overrides:
activateOptions
in classAppenderSkeleton
-
requiresLayout
public boolean requiresLayout()The SyslogAppender requires a layout. Hence, this method returnstrue
.- Since:
- 0.8.4
-
setSyslogHost
The SyslogHost option is the name of the the syslog host where log output should go. A non-default port can be specified by appending a colon and port number to a host name, an IPv4 address or an IPv6 address enclosed in square brackets. WARNING If the SyslogHost is not set, then this appender will fail. -
getSyslogHost
Returns the value of the SyslogHost option. -
setFacility
Set the syslog facility. This is the Facility option.The
facilityName
parameter must be one of the strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. Case is unimportant.- Since:
- 0.8.1
-
getFacility
Returns the value of the Facility option. -
setFacilityPrinting
public void setFacilityPrinting(boolean on) If the FacilityPrinting option is set to true, the printed message will include the facility name of the application. It is false by default. -
getFacilityPrinting
public boolean getFacilityPrinting()Returns the value of the FacilityPrinting option. -
getHeader
public final boolean getHeader()If true, the appender will generate the HEADER part (that is, timestamp and host name) of the syslog packet. Default value is false for compatibility with existing behavior, however should be true unless there is a specific justification.- Since:
- 1.2.15
-
setHeader
public final void setHeader(boolean val) Returns whether the appender produces the HEADER part (that is, timestamp and host name) of the syslog packet.- Since:
- 1.2.15
-