Is there a way to pass json formatter using appsettings.json?

See original GitHub issue

Somehow like this

"Serilog": {
    "MinimumLevel": {
      "Default": "Debug",
      "Override": {
        "Microsoft": "Fatal",
        "System": "Fatal",
      }
    },
    "Using": [
      "Serilog.Sinks.File",
    ],
    "WriteTo": [
      {
        "Name": "File",
        "Args": {
          "pathFormat": "logs/log.log",
          "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
        }
      }
    ]
  }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tsimbalarcommented, Mar 13, 2019

Hi,

yes this should work, and I believe you should be able to omit the , Serilog at the end of "Serilog.Formatting.Json.JsonFormatter, Serilog"

You can find more configuration examples in https://github.com/tsimbalar/serilog-settings-comparison/blob/master/docs/README.md

0reactions
cocowallacommented, Jun 26, 2020

@mincasoft the WriteTo.File() method takes an Encoding item as a parameter (you can see it in the comment above). If this isn’t what you’re looking for, would appreciate if you could open a new issue 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to set Serilog formatter variables via ...
json file would be represented in C# as something like this: Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(configuration) .
Read more >
Customized JSON formatting with Serilog
This post collects all kinds of JSON formatting examples using ExpressionTemplate , and I'll add to them as new questions come my way...
Read more >
How to get json values and pass it in same appsetting ...
To get the json values from the appsetting.json file, you could use the Configuration. For example: Consider the following appsettings.json file ...
Read more >
How to Read AppSettings Values From a JSON File in . ...
Explains how to read AppSettings values from a JSON file in ASP.NET Core including rich examples and code samples.
Read more >
Appsettings.json in .NET: How to read and get a value
The appsettings. json is used in .NET and .NET Core applications to read and get a value from the configuration file using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found