rnwood / smtp4dev

smtp4dev - the fake smtp email server for development and testing
BSD 3-Clause "New" or "Revised" License
3.18k stars 345 forks source link

Logging - Improve the Documentation #983

Open thecliguy opened 3 years ago

thecliguy commented 3 years ago

The Configuration page on the wiki shows an example config file where logging is implemented as follows:

"Logging": {
    "IncludeScopes": false,
    "Debug": {
        "LogLevel": {
            "Default": "Warning"
        }
    },
    "Console": {
        "LogLevel": {
            "Default": "Warning"
        }
    }
}

At first it wasn't obvious to me how these settings worked...

Having now done some further research I believe that logging is implemented using the .Net logging API and Microsoft have done a pretty nice job at documenting it

Obviously it's not worth writing lots of documentation when Microsoft have done that work already - but it would have saved me a lot of time if the Configuration page included a sentence or two explaining how logging is implemented with a link to Microsoft's documentation.

thecliguy commented 3 years ago

Hummm... Now I'm confused again...

Has the .Net logging API been replaced with the serilog library since version 3.1.3-ci20210907103?

jafin commented 3 years ago

@thecliguy, the more recent CI builds have serilog logging, but the official release (at time 3.1.3.2) is using net logging. The interesting challenge here is maintaining the documentation for both versions. Out of the box, the logging should be essentially on par with the prior logging solution. Perhaps adding to document to describe both with a version note attached to avoid confusion.

If you are looking at extended loggers to different sinks etc, then I think some documentation on how to do that would be beneficial. Details of configuring serilog via the appsettings.json can be found here https://github.com/serilog/serilog-settings-configuration

thecliguy commented 3 years ago

@jafin In the recent CI builds, can you choose whether to use the .Net logging API or the serilog library? Or has serilog completely replaced the .Net logging API?

jafin commented 2 years ago

@thecliguy net logging has been replaced with serilog logging in the CI build.

Ra5CZ commented 1 day ago

I tried to debug smt4dev with logging, but I don't get any debug logs from SmtpServer.cs (for example from the private async Task Core() method) into the console. I've been trying for two days to figure out why Microsoft.Extensions.Logging doesn't use Serilog in this case, but without success. Can any of you think of a reason why? I have in appsettings:

"Serilog": {
    "Using": [ "Serilog", "Serilog.Sinks.Console" ],
    "MinimumLevel": {
      "Default": "Debug",
      "Override": {
        // For detailed diagnostics set to Information
        "Microsoft": "Warning",
        "Microsoft.EntityFrameworkCore": "Warning"
      }
    },
    "WriteTo": [
      {
        "Name": "Console",
        "args": {
          "outputTemplate": "{Message:lj}{NewLine}{Exception}"
        }
      }
    ],
    "Properties": {
      "ApplicationName": "Smtp4Dev"
    }
  },