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

Support Async Wrapper sink #64

Closed
cdavid opened this issue Jul 17, 2017 · 2 comments
Closed

Support Async Wrapper sink #64

cdavid opened this issue Jul 17, 2017 · 2 comments

Comments

@cdavid
Copy link

cdavid commented Jul 17, 2017

Hi

I am looking to use Serilog in a .NET Core project (using appsettings.json) in conjunction with the File / RollingFile sinks and have the entire thing be configurable at runtime (using the Serilog.Settings.Configuration). I noticed that there is a performance hit when doing that (at scale), so I was thinking about using the AsyncWrapper to reduce the potential I/O bottleneck.

Unfortunately, the project says it has no support for appsettings.json and I was not able to tell how to make the two sinks work together. If there is, please disregard the rest of my email and please let me know how to do it. If there is not...

Fortunately, I am willing to make this change myself and contribute it here :) - I am just wondering what is a good way to do it.

The way that I thought of it, there would be a "UseAsync" attribute on one of the "WriteTo" objects (default = false if the attribute does not exist) as below:

{
  "Serilog": {
    "Using":  ["Serilog.Sinks.Literate"],
    "MinimumLevel": "Debug",
    "WriteTo": [
      { 
         "Name": "LiterateConsole",
         "UseAsync": "true"
      },
      { 
         "Name": "File",
         "Args":
         {
              "path": "%TEMP%\\Logs\\serilog-configuration-sample.txt"
         }
      }
    ],
    "Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"],
    "Properties": {
		"Application": "Sample"
    }
  }
}

Thoughts, opinions?

@nblumhardt
Copy link
Member

Hi @cdavid - thanks for getting in touch. It's just the Async README that's outdated here:

  "WriteTo": [
    {
      "Name": "Async",
      "Args": {
        "configure": [{
            "Name": "LiterateConsole"
        }]
     },

(Unfortunately the syntax of the JSON configuration provider is a little verbose here - we'd like to refine it further but haven't got a solid idea of where to take it yet. Thanks for the UseAsync suggestion.)

@cdavid
Copy link
Author

cdavid commented Jul 18, 2017

Thanks for this, works!

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

2 participants