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 intstatic final intsecurity/authorization messagesstatic final intsecurity/authorization messages (private)static final intclock daemonstatic final intSystem daemonsstatic final intftp daemonstatic final intKernel messagesstatic final intreserved for local usestatic final intreserved for local usestatic final intreserved for local usestatic final intreserved for local usestatic final intreserved for local usestatic final intreserved for local usestatic final intreserved for local usestatic final intreserved for local usestatic final intline printer subsystemstatic final intMail systemstatic final intnetwork news subsystemstatic final intmessages generated internally by syslogdstatic final intRandom user-level messagesstatic final intUUCP subsystemprotected static final intFields 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 TypeMethodDescriptionvoidThis method returns immediately as options are activated when they are set.voidappend(LoggingEvent event) Subclasses ofAppenderSkeletonshould implement this method to perform actual logging.voidclose()Release any resources held by this SyslogAppender.Returns the value of the Facility option.static intgetFacility(String facilityName) Returns the integer value corresponding to the named syslog facility, or -1 if it couldn't be recognized.booleanReturns the value of the FacilityPrinting option.static StringgetFacilityString(int syslogFacility) Returns the specified syslog facility as a lower-case String, e.g.final booleanIf 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.booleanThe SyslogAppender requires a layout.voidsetFacility(String facilityName) Set the syslog facility.voidsetFacilityPrinting(boolean on) If the FacilityPrinting option is set to true, the printed message will include the facility name of the application.final voidsetHeader(boolean val) Returns whether the appender produces the HEADER part (that is, timestamp and host name) of the syslog packet.voidsetSyslogHost(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:AppenderSkeletonSubclasses ofAppenderSkeletonshould implement this method to perform actual logging. See alsoAppenderSkeleton.doAppendmethod.- Specified by:
appendin classAppenderSkeleton
-
activateOptions
public void activateOptions()This method returns immediately as options are activated when they are set.- Specified by:
activateOptionsin interfaceOptionHandler- Overrides:
activateOptionsin 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
facilityNameparameter 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
-