Class RemoteSyslogAppender
Logs events to a remote syslog daemon.
public class RemoteSyslogAppender : UdpAppender, IBulkAppender, IAppender, IOptionHandler
- Inheritance
-
RemoteSyslogAppender
- Implements
- Inherited Members
Remarks
The BSD syslog protocol is used to remotely log to a syslog daemon. The syslogd listens for for messages on UDP port 514.
The syslog UDP protocol is not authenticated. Most syslog daemons do not accept remote log messages because of the security implications. You may be able to use the LocalSyslogAppender to talk to a local syslog service.
There is an RFC 3164 that claims to document the BSD Syslog Protocol. This RFC can be seen here: http://www.faqs.org/rfcs/rfc3164.html. This appender generates what the RFC calls an "Original Device Message", i.e. does not include the TIMESTAMP or HOSTNAME fields. By observation this format of message will be accepted by all current syslog daemon implementations. The daemon will attach the current time and the source hostname or IP address to any messages received.
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 RemoteSyslogAppender.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 Domain).
Constructors
RemoteSyslogAppender()
Initializes a new instance of the RemoteSyslogAppender class.
public RemoteSyslogAppender()
Remarks
This instance of the RemoteSyslogAppender class is set up to write to a remote syslog daemon.
Properties
Facility
Syslog facility
public RemoteSyslogAppender.SyslogFacility Facility { get; set; }
Property Value
Remarks
Set to one of the RemoteSyslogAppender.SyslogFacility values. The list of facilities is predefined and cannot be extended. The default value is User.
Identity
Message identity
public PatternLayout 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 Domain).
Methods
ActivateOptions()
Initialize the options for this appender
public override void ActivateOptions()
Remarks
Initialize the level to syslog severity mappings set on this appender.
AddMapping(LevelSeverity)
Add a mapping of level to severity
public void AddMapping(RemoteSyslogAppender.LevelSeverity mapping)
Parameters
mappingRemoteSyslogAppender.LevelSeverityThe mapping to add
Remarks
Add a RemoteSyslogAppender.LevelSeverity mapping 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.
GeneratePriority(SyslogFacility, SyslogSeverity)
Generate a syslog priority.
public static int GeneratePriority(RemoteSyslogAppender.SyslogFacility facility, RemoteSyslogAppender.SyslogSeverity severity)
Parameters
facilityRemoteSyslogAppender.SyslogFacilityThe syslog facility.
severityRemoteSyslogAppender.SyslogSeverityThe syslog severity.
Returns
- int
A syslog priority.
Remarks
Generate a syslog priority.
GetSeverity(Level)
Translates a log4net level to a syslog severity.
protected virtual RemoteSyslogAppender.SyslogSeverity GetSeverity(Level level)
Parameters
levelLevelA log4net level.
Returns
- RemoteSyslogAppender.SyslogSeverity
A syslog severity.
Remarks
Translates a log4net level to a syslog severity.