src/Serilog.Sinks.EventLog/Sinks/EventLog/EventLogSink.cs
/// <summary>
/// Emit the provided log event to the sink.
/// </summary>
/// <param name="logEvent">The log event to write.</param>
/// <remarks>
/// <see cref="LogEventLevel.Debug" />, <see cref="LogEventLevel.Information" /> and <see cref="LogEventLevel.Verbose" /> are registered as <see cref="EventLogEntryType.Information" />.
/// <see cref="LogEventLevel.Error" />, <see cref="LogEventLevel.Fatal" /> are registered as <see cref="EventLogEntryType.Error" />.
/// <see cref="LogEventLevel.Warning" /> are registered as <see cref="EventLogEntryType.Warning" />.
/// The Event ID in the Windows log will be set to the integer value of the <paramref name="logEvent"/>'s <see cref="LogEvent.Level"/> property, so that the log can be filtered with more granularity.</remarks>
Emit the provided log event to the sink.
Emit the provided log event to the sink .
public void Emit(LogEvent logEvent)
        {
            if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
            var type = LevelToEventLogEntryType(logEvent.Level);
            var payloadWriter = new StringWriter();
            _textFormatter.Format(logEvent, payloadWriter);
            var payload = payloadWriter.ToString();
            if (payload.Length > MaximumPayloadLengthChars)
            {
                SelfLog.WriteLine("Trimming long event log entry payload to {0} characters", MaximumPayloadLengthChars);
                payload = payload.Substring(0, MaximumPayloadLengthChars);
            }
            _log.WriteEntry(payload, type, _eventIdProvider.ComputeEventId(logEvent));
        }
public void Emit ( LogEvent logEvent ) { if ( logEvent == null ) throw new ArgumentNullException ( nameof ( logEvent ) ) ; var type = LevelToEventLogEntryType ( logEvent . Level ) ; var payloadWriter = new StringWriter ( ) ; _textFormatter . Format ( logEvent , payloadWriter ) ; var payload = payloadWriter . ToString ( ) ; if ( payload . Length > MaximumPayloadLengthChars ) { SelfLog . WriteLine ( " " , MaximumPayloadLengthChars ) ; payload = payload . Substring ( 0 , MaximumPayloadLengthChars ) ; } _log . WriteEntry ( payload , type , _eventIdProvider . ComputeEventId ( logEvent ) ) ; }
Emit the provided log event to the sink.
Emit the provided log event to the sink .
// The payload is limited in length and allowed chars, see: https://msdn.microsoft.com/en-us/library/e29k5ebc%28v=vs.110%29.aspx
logEvent
LogEvent
The log event to write.
The log event to write .
remarks
,  and  are registered as .
,  are registered as .
are registered as .
The Event ID in the Windows log will be set to the integer value of the 's  property, so that the log can be filtered with more granularity.
and are registered as . are registered as . are registered as . The Event ID in the Windows log will be set to the integer value of the ' s property so that the log can be filtered with more granularity .