--- name: ansight-logging-serilog description: Use this skill when integrating Serilog with Ansight so Serilog events are mirrored into Ansight session timelines through a custom sink. --- # Ansight Logging Skill For Serilog Use this skill when a user wants Serilog events to appear in Ansight session data. ## Goal Attach an Ansight sink to the existing Serilog pipeline so application logs are mirrored into Ansight with `Runtime.Event(...)`. ## Required Constraints - keep existing Serilog sinks and enrichers intact - add an Ansight sink to Serilog; do not try to forward Ansight diagnostics out and stop there - map Serilog levels into `AppEventType` - emit exception events separately when `LogEvent.Exception` is present ## Workflow 1. Inspect the current `LoggerConfiguration`. 2. Add an `ILogEventSink` implementation that forwards log events into Ansight. 3. Map log levels: - `Verbose` and `Debug` -> `AppEventType.Debug` - `Information` -> `AppEventType.Info` - `Warning` -> `AppEventType.Warning` - `Error` and `Fatal` -> `AppEventType.Error` 4. Preserve the rest of the logging pipeline. 5. Build and verify the app. ## Implementation Pattern ```csharp Log.Logger = new LoggerConfiguration() .WriteTo.Sink(new AnsightSerilogSink()) .CreateLogger(); ``` In real integrations, keep any existing `WriteTo` sinks and enrichers already configured by the app. ## Done Criteria - Serilog events appear in Ansight timelines - existing Serilog sinks continue to receive the same events - level mapping is consistent - exceptions are mirrored into Ansight