Skip to content

Operations and processes

This library performs 12 distinct operations across its three host-style loggers (web, Windows Service, console), spanning configuration/bootstrap, log-entry emission, exception formatting, outbound delivery to the SAIF Logging API, and disposal.

Operation catalog

ID Operation Primary component Business rules
OP-01 Configure the web logger (SaifLog) SaifLog.Configure BR-LOG-01, BR-LOG-02, BR-LOG-04, BR-LOG-08
OP-02 Configure the Windows Service logger (SaifWindowsServiceLog) SaifWindowsServiceLog.Configure BR-LOG-01, BR-LOG-02, BR-LOG-08, BR-LOG-09
OP-03 Configure the console logger (ConsoleLogService) ConsoleLogService.Configure BR-LOG-12, BR-LOG-18
OP-04 Apply appsettings.json logger overrides SaifLogBase.ApplyLoggingSettingOverrides BR-LOG-03, BR-LOG-04, BR-LOG-05
OP-05 Emit an information/warning log entry SaifLogBase log methods BR-LOG-06, BR-LOG-07, BR-LOG-08
OP-06 Emit an exception/error log entry SaifLogBase log methods; ExceptionFormatService BR-LOG-06, BR-LOG-08, BR-LOG-10
OP-07 Format a web-context exception ExceptionFormatServiceForWeb BR-LOG-10, BR-LOG-11
OP-08 Post a log entry to the Logging API LoggingApiSink.Emit BR-LOG-13, BR-LOG-14, BR-LOG-15
OP-09 Write a console log entry ConsoleLogService; LogWriter BR-LOG-12, BR-LOG-18
OP-10 Correlate a log entry with the current activity SaifLogBase log methods BR-LOG-07
OP-11 Wire ASP.NET Core logging to the configured Serilog pipeline WebHostBuilderExtensions.UseSaifLog BR-LOG-16, BR-LOG-17
OP-12 Dispose and flush a configured logger SaifLogBase.Dispose; ConsoleLogService.Dispose BR-LOG-06, BR-LOG-12

Process flow diagram

The following diagram visualizes the primary operational flow across these twelve operations, from configuration through log emission to disposal.

flowchart TD
    A[Host calls Configure] --> B{Read Environment API threshold}
    B -->|present or resolved| C[Apply appsettings.json overrides - OP-04]
    B -->|missing / invalid| B1["ArgumentException - Configure fails;<br>IsConfigured stays false on first attempt,<br>or keeps its prior value on a later failed attempt"]
    C --> D["Build Serilog pipeline + sinks"]
    D --> E["IsConfigured = true"]
    E --> F[Caller invokes a log method]
    F --> G{Entry type}
    G -->|info / warning| H[Emit information log entry - OP-05]
    G -->|exception| I[Format exception - OP-06 / OP-07]
    H --> J[Correlate with Activity - OP-10]
    I --> J
    J --> K{IsConfigured?}
    K -->|No| K1["Debug.Write diagnostic only; log ID still returned"]
    K -->|Yes| L["Write to ILogger, Serilog sinks"]
    L --> M{Sink}
    M -->|Logging API sink| N["IsException? - route to Send or SendException - OP-08"]
    M -->|Console / Event Log| O[Automatic sink write]
    F2["Host explicitly calls<br>WriteToAppLog / GetLog.Write*"] --> O2["Write console log file entry - OP-09<br>(separate explicit path, not a Serilog sink)"]
    N -->|unsuccessful RequestResult| P[Report to Console/Debug only]
    Q[Host disposes the logger] --> R[Dispose and flush - OP-12]

Failure and edge-case behavior

  • If neither the application-named nor the tracingdefaults base-threshold key resolves to a valid level, Configure throws ArgumentException and the logger does not become configured by this call — IsConfigured stays false if this is the first Configure attempt, or keeps its prior true value if a previously-successful Configure is being retried (BR-LOG-08); every subsequent log call still returns a generated correlation ID (for exception-bearing calls, only once the pre-ID exception-formatting steps succeed) but writes only a Debug-level diagnostic trace instead of reaching ILogger/Serilog when IsConfigured is false.
  • An invalid SaifLogging:BaseLevel value fails ConsoleLogService's constructor, which fails DI resolution of IConsoleLogService for the whole host.
  • A SaifLogging:Loggers override entry with an invalid or missing Type throws SaifLogConfigurationException; one with a missing Level throws ArgumentException (see BR-LOG-04).
  • SaifWindowsServiceLog never reads logerrorroute, so error entries from that host are posted with a null route.
  • LoggingApiSink.Emit is async void with no try/catch anywhere in the class; an unsuccessful HTTP result is reported only to Console/Debug, but a thrown exception from the POST call itself is not caught anywhere in this sink — there is no universal failure-containment guarantee (BR-LOG-15).
  • The console host's auxiliary file channels (file0–file4) are not automatic Serilog sinks fanned out from the main pipeline; they are only reached when the host explicitly calls WriteToAppLog/GetLog(logType).Write* (OP-09).

Sources

  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SaifLogBase.cs
  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SaifLog.cs
  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SaifWindowsServiceLog.cs
  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/ConsoleLogService.cs
  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/Loggers/LoggingApiSink.cs
  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/ExceptionFormatter/ExceptionFormatService.cs
  • src/SAIF.NetCore.Logging/SAIF.NetCore.Logging/SAIF.NetCore.Logging/Web/WebHostBuilderExtensions.cs