Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is correct configuration in appsettings.json? #48

Open
ziga34 opened this issue Aug 6, 2019 · 3 comments
Open

What is correct configuration in appsettings.json? #48

ziga34 opened this issue Aug 6, 2019 · 3 comments

Comments

@ziga34
Copy link

ziga34 commented Aug 6, 2019

Hello,

It's tough for me to figure it out, so please let me know what is the correct config:

{
  "Serilog": {
    "Using": [ "Serilog.Sinks.Async" ], <--- Is it ok, or should be Serilog.Sinks.RollingFileAlternate?
    "WriteTo": [
      {
        "Name": "Async",
        "Args": {
          "bufferSize": 100000, <-- does this belongs here? Or elsewhere?
          "blockWhenFull": true, <-- does this belongs here? Or elsewhere?
          "configure": [
            {
              "Name": "RollingFileAlternate",
              "Args": {
                "logDirectory": "D:\\log",
                "fileSizeLimitBytes": 1048576,
                "outputTemplate": "[{Timestamp:o} {Level:u3}] {Message:lj} {Properties:j}{NewLine}{Exception}"
              }
            }
          ]
        }
      }
    ]
  }
}
@lonix1
Copy link

lonix1 commented Mar 1, 2021

ensure you install the nuget Serilog.Sinks.Async

example: async sink that wraps file sink:

{
  "Name": "Async",
  "Args": {
    "configure": [
      {
        "Name": "File",
        "Args": {
          "path": "logs/app.log",
          "rollingInterval": "Day",
          "formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact"
        }
      }
    ]
  }
}

The docs for this are unclear, they should be updated with a proper example like above.

@bartelink
Copy link
Member

bartelink commented Mar 1, 2021

@lonix1 Your suggestion looks good - Async over a console log is also debatable so, if you can make the time to do a PR based on the above it'd be great.

(Also your other issue pretty much duplicates the questions asked within this, no?)

@raheinz57
Copy link

raheinz57 commented May 1, 2023

The monitor implementation can be configured using a Serilog hook in appsettings.json. I have uploaded an implementation that loads the monitor via appsettings.json
AsyncMonitorHook.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants