serilog-sinks-eventlog
serilog-sinks-eventlog copied to clipboard
Provide some means to use reliable MessageId
My understanding is that the EventId I see in the Windows EventLog is the MessageId and is somewhat dynamic derived from Serilog. This makes it very difficult, if not impossible to build automated rules in a central monitoring system, as the EventId may change between different versions of an application using Serilog. Is there a way to create reliable EventId / MessageId's?
Transferring to Serilog.Sinks.EventLog which seems slightly more relevant; Serilog is completely general, you can explicitly attach properties with any name or value, it sounds like your request relates to the built-in properties the Windows Event Log supports.
The event ids are "event types", you can read about them here:
https://nblumhardt.com/2016/07/event-types-structured-logging-concepts-in-net-4/
They're stable as long as the message template of an event is stable. Generally, if you change the description of an event it'll change its meaning/type anyway, but you can definitely get more specific by attaching event names of your own.
But the Windows Event Log is an awkward, lossy channel to sit between your applications and your monitoring system. Perhaps the best idea is to just plug in a sink that's specific to the monitoring system, and then get full-fidelity structured events (with your own custom properties) across to alert on?
My understanding is that the EventId I see in the Windows EventLog is the MessageId and is somewhat dynamic derived from Serilog. This makes it very difficult, if not impossible to build automated rules in a central monitoring system, as the EventId may change between different versions of an application using Serilog. Is there a way to create reliable EventId / MessageId's?
Have you looked at implementing your own IEventIdProvider?
If you use Microsoft.Logging.ILogger interface like in nblumhardts link you can send in what EventId you want when logging. (use new SerilogLoggerFactory().CreateLogger("name") to get Microsoft ILogger). Then you just need to pluck out the Id from the logEvent.Properties in your implementation of ComputeEventId.
Closing as I think IEventIdProvider should cover this.