adams85 / filelogger

A lightweight yet feature-rich file logger implementation for the Microsoft.Extensions.Logging framework.
MIT License
147 stars 22 forks source link

Structured logging to file, simple logging to console #20

Closed pinx closed 2 years ago

pinx commented 2 years ago

Could you provide a simple example of how to configure logging, such that the log files are filled with structured logging and the console with human readable logging? Ideally, these settings would make it happen:

    "Console": {
      "FormatterName": "simple",
      "FormatterOptions": {
        "SingleLine": true
      }
    },
    "File": {
      "FormatterName": "json",
      "FormatterOptions": {
        "SingleLine": true
      },
      "Files": [
        {
          "Path": "default-<date>.log"
        }
      ]
    }
adams85 commented 2 years ago

The file logger library doesn't offer structured logging out-of-the-box currently. Although it's doable through some subclassing and overriding of methods, it requires pretty heavy customization.

I have plans to include structured logging capabilities (JSON, expectedly) in the future but that will only happen in a new major version because it will need some breaking changes to the public APIs.

adams85 commented 2 years ago

Implemented in v3.3.0.