public class SyslogAppender extends AppenderSkeleton
Modifier and Type | Field and Description |
---|---|
private SimpleDateFormat |
dateFormat
Date format used if header = true.
|
protected static int |
FACILITY_OI |
(package private) boolean |
facilityPrinting |
(package private) String |
facilityStr |
private boolean |
header
If true, the appender will generate the HEADER (timestamp and host name)
part of the syslog packet.
|
private boolean |
layoutHeaderChecked
Set to true after the header of the layout has been sent or if it has none.
|
private String |
localHostname
Host name used to identify messages from this appender.
|
static int |
LOG_AUTH
security/authorization messages
|
static int |
LOG_AUTHPRIV
security/authorization messages (private)
|
static int |
LOG_CRON
clock daemon
|
static int |
LOG_DAEMON
System daemons
|
static int |
LOG_FTP
ftp daemon
|
static int |
LOG_KERN
Kernel messages
|
static int |
LOG_LOCAL0
reserved for local use
|
static int |
LOG_LOCAL1
reserved for local use
|
static int |
LOG_LOCAL2
reserved for local use
|
static int |
LOG_LOCAL3
reserved for local use
|
static int |
LOG_LOCAL4
reserved for local use
|
static int |
LOG_LOCAL5
reserved for local use
|
static int |
LOG_LOCAL6
reserved for local use
|
static int |
LOG_LOCAL7
reserved for local use
|
static int |
LOG_LPR
line printer subsystem
|
static int |
LOG_MAIL
Mail system
|
static int |
LOG_NEWS
network news subsystem
|
static int |
LOG_SYSLOG
messages generated internally by syslogd
|
static int |
LOG_USER
Random user-level messages
|
static int |
LOG_UUCP
UUCP subsystem
|
(package private) SyslogQuietWriter |
sqw |
protected static int |
SYSLOG_HOST_OI |
(package private) int |
syslogFacility |
(package private) String |
syslogHost |
(package private) static String |
TAB |
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
Constructor and Description |
---|
SyslogAppender() |
SyslogAppender(Layout layout,
int syslogFacility) |
SyslogAppender(Layout layout,
String syslogHost,
int syslogFacility) |
Modifier and Type | Method and Description |
---|---|
void |
activateOptions()
This method returns immediately as options are activated when they
are set.
|
void |
append(LoggingEvent event)
Subclasses of
AppenderSkeleton should implement this
method to perform actual logging. |
void |
close()
Release any resources held by this SyslogAppender.
|
String |
getFacility()
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 |
getFacilityPrinting()
Returns the value of the FacilityPrinting option.
|
static String |
getFacilityString(int syslogFacility)
Returns the specified syslog facility as a lower-case String,
e.g.
|
boolean |
getHeader()
If true, the appender will generate the HEADER part (that is, timestamp and host name)
of the syslog packet.
|
private String |
getLocalHostname()
Get the host name used to identify this appender.
|
private String |
getPacketHeader(long timeStamp)
Gets HEADER portion of packet.
|
String |
getSyslogHost()
Returns the value of the SyslogHost option.
|
private void |
initSyslogFacilityStr() |
boolean |
requiresLayout()
The SyslogAppender requires a layout.
|
private void |
sendLayoutMessage(String msg)
Set header or footer of 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.
|
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.
|
private void |
splitPacket(String header,
String packet) |
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
public static final int LOG_KERN
public static final int LOG_USER
public static final int LOG_MAIL
public static final int LOG_DAEMON
public static final int LOG_AUTH
public static final int LOG_SYSLOG
public static final int LOG_LPR
public static final int LOG_NEWS
public static final int LOG_UUCP
public static final int LOG_CRON
public static final int LOG_AUTHPRIV
public static final int LOG_FTP
public static final int LOG_LOCAL0
public static final int LOG_LOCAL1
public static final int LOG_LOCAL2
public static final int LOG_LOCAL3
public static final int LOG_LOCAL4
public static final int LOG_LOCAL5
public static final int LOG_LOCAL6
public static final int LOG_LOCAL7
protected static final int SYSLOG_HOST_OI
protected static final int FACILITY_OI
static final String TAB
int syslogFacility
String facilityStr
boolean facilityPrinting
SyslogQuietWriter sqw
String syslogHost
private boolean header
private final SimpleDateFormat dateFormat
private String localHostname
private boolean layoutHeaderChecked
public SyslogAppender()
public SyslogAppender(Layout layout, int syslogFacility)
public SyslogAppender(Layout layout, String syslogHost, int syslogFacility)
public void close()
private void initSyslogFacilityStr()
public static String getFacilityString(int syslogFacility)
public static int getFacility(String facilityName)
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.private void splitPacket(String header, String packet)
public void append(LoggingEvent event)
AppenderSkeleton
AppenderSkeleton
should implement this
method to perform actual logging. See also AppenderSkeleton.doAppend
method.append
in class AppenderSkeleton
public void activateOptions()
activateOptions
in interface OptionHandler
activateOptions
in class AppenderSkeleton
public boolean requiresLayout()
true
.public void setSyslogHost(String syslogHost)
public String getSyslogHost()
public void setFacility(String facilityName)
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.
public String getFacility()
public void setFacilityPrinting(boolean on)
public boolean getFacilityPrinting()
public final boolean getHeader()
public final void setHeader(boolean val)
private String getLocalHostname()
private String getPacketHeader(long timeStamp)
timeStamp
- number of milliseconds after the standard base time.private void sendLayoutMessage(String msg)
msg
- message body, may not be null.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses