Disable console sink in release environments?

Viewed 112

quick question,

I run console sink for an asp.net core webapp. We use the console sink for development - but for performance i think it would be best to disable the sink in our production environment.

I'm assuming this sink pushes logs to stdout regardless of whether there are any listeners, hence turing the sink off would be better. Please do correct me if i'm wrong.

Would i be able to turn off the sink under a specified condition/property/commandline arg etc. or would performance not be impacted at all? Would i be able to disable the sink based on whether there are any listeners?

My config is as follows:

{
  "Serilog": {
    "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Microsoft": "Warning",
        "Microsoft.Hosting.Lifetime": "Information",
        "System": "Warning",
        "System.Net.Http.HttpClient": "Warning",
        "Hangfire": "Warning"
      }
    },
    "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
    "Enrich": [ "FromLogContext" ],
    "WriteTo": [
      {
        "Name": "Console",
        "Args": {
          "outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} {SourceContext}{NewLine}{Exception}"
        }
      },
      {
        "Name": "File",
        "Args": {
          "path": "%CUROUTDIR%\\..\\Logs\\%PROCESSNAME%\\%PROCESSNAME% .txt",
          "rollingInterval": "Day",
          "rollOnFileSizeLimit": true,
          "retainedFileCountLimit": 31,
          "fileSizeLimitBytes": 5242880,
          "outPutTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} {Properties:j}{NewLine}{Exception}"
        }
      }
    ]
  }
}

0 Answers
Related