Class LocalSyslogAppender
Logs events to a local syslog service.
public class LocalSyslogAppender : AppenderSkeleton, IBulkAppender, IAppender, IOptionHandler, IFlushable
- Inheritance
-
LocalSyslogAppender
- Implements
- Inherited Members
Remarks
note
This appender uses the POSIX libc library functions openlog, syslog, and closelog.
If these functions are not available on the local system then this appender will not work!
The functions openlog, syslog, and closelog are specified in SUSv2 and
POSIX 1003.1-2001 standards. These are used to log messages to the local syslog service.
This appender talks to a local syslog service. If you need to log to a remote syslog daemon and you cannot configure your local syslog service to do this you may be able to use the RemoteSyslogAppender to log via UDP.
Syslog messages must have a facility and and a severity. The severity is derived from the Level of the logging event. The facility must be chosen from the set of defined syslog LocalSyslogAppender.SyslogFacility values. The facilities list is predefined and cannot be extended.
An identifier is specified with each log message. This can be specified by setting the Identity property. The identity (also know as the tag) must not contain white space. The default value for the identity is the application name (from ApplicationFriendlyName).
Constructors
LocalSyslogAppender()
Initializes a new instance of the LocalSyslogAppender class.
public LocalSyslogAppender()
Remarks
This instance of the LocalSyslogAppender class is set up to write to a local syslog service.
Properties
Facility
Syslog facility
public LocalSyslogAppender.SyslogFacility Facility { get; set; }
Property Value
Remarks
Set to one of the LocalSyslogAppender.SyslogFacility values. The list of facilities is predefined and cannot be extended. The default value is User.
Identity
Message identity
public string Identity { get; set; }
Property Value
Remarks
An identifier is specified with each log message. This can be specified by setting the Identity property. The identity (also know as the tag) must not contain white space. The default value for the identity is the application name (from ApplicationFriendlyName).
RequiresLayout
This appender requires a Layout to be set.
protected override bool RequiresLayout { get; }
Property Value
- bool
true
Remarks
This appender requires a Layout to be set.
Methods
ActivateOptions()
Initialize the appender based on the options set.
public override void ActivateOptions()
Remarks
This is part of the IOptionHandler delayed object activation scheme. The ActivateOptions() method must be called on this object after the configuration properties have been set. Until ActivateOptions() is called this object is in an undefined state and must not be used.
If any of the configuration properties are modified then ActivateOptions() must be called again.
AddMapping(LevelSeverity)
Add a mapping of level to severity
public void AddMapping(LocalSyslogAppender.LevelSeverity mapping)
Parameters
mappingLocalSyslogAppender.LevelSeverityThe mapping to add
Remarks
Adds a LocalSyslogAppender.LevelSeverity to this appender.
Append(LoggingEvent)
This method is called by the AppenderSkeleton.DoAppend(LoggingEvent) method.
protected override void Append(LoggingEvent loggingEvent)
Parameters
loggingEventLoggingEventThe event to log.
Remarks
Writes the event to a remote syslog daemon.
The format of the output will depend on the appender's layout.
GetSeverity(Level)
Translates a log4net level to a syslog severity.
protected virtual LocalSyslogAppender.SyslogSeverity GetSeverity(Level level)
Parameters
levelLevelA log4net level.
Returns
- LocalSyslogAppender.SyslogSeverity
A syslog severity.
Remarks
Translates a log4net level to a syslog severity.
OnClose()
Close the syslog when the appender is closed
protected override void OnClose()
Remarks
Close the syslog when the appender is closed