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

[Docs] Configuration for json #68

Open
lonix1 opened this issue Mar 1, 2021 · 9 comments
Open

[Docs] Configuration for json #68

lonix1 opened this issue Mar 1, 2021 · 9 comments

Comments

@lonix1
Copy link

lonix1 commented Mar 1, 2021

The docs are not clear about the json option.

If specifying async in appsettings.json, how do we also specify:

  • Buffering & Dropping
  • Health Monitoring via the Monitor and Inspector interfaces
  • Blocking

A very simple example would be helpful.

Thanks.

@bartelink
Copy link
Member

There's a generic parsing mechanism supplied by Serilog. While documenting it at the sink level would be nice for some users, it's definitely not a universally used feature so hard to imagine all sinks getting it; that's not to say a PR demonstrating a working config wouldn't work.

I'd suggest asking this as a question on stackoverflow instead; you're far more likely to run into someone that understands the config file mechanisms and time to answer there; in general people monitor the serilog tag.

@lonix1
Copy link
Author

lonix1 commented Mar 1, 2021

I don't understand... are you saying that those features are not available when using json?

@lonix1
Copy link
Author

lonix1 commented Mar 1, 2021

Ok my findings so far for anyone else who is interested:

{
  "Name": "Async",
  "Args": {
    "bufferSize": 10,                               // <--- "Buffering & Dropping"
    "blockWhenFull": true,                          // <--- "Blocking"
    "configure": [
      {
        "Name": "File",
        "Args": {
          "path": "./logs/app.log",
          "formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact"
        }
      }
    ]
  }
}

I still haven't figured out "Health Monitoring via the Monitor and Inspector interfaces". If anyone knows, please let me know.

@bartelink
Copy link
Member

I am saying that despite having written some extensions for this sink, I've never used the json config mechanism and it's not on my list.

In other words, understanding how to use the json config mechanism is orthogonal to this sink's behavior.

The other thing is that there are going to be far more people looking at https://stackoverflow.com/questions/tagged/serilog than watching this sink; thats why in general it's best to discuss those things there - you'll get answers quicker.

In particular the syntax and/or whether it's possible to configure those interfaces via JSON is something I'd be guessing at, whereas there are tens of thousands of people who have attempted configuring such aspects using the serilog config mechanism, and they're likely to be able to tell you whether this one can be made to work.

(If you're patient, someone will eventually respond; just saying the best way to cover these things for all concerned is to use SO as the primary mechanism.)

@lonix1
Copy link
Author

lonix1 commented Mar 1, 2021

I fully agree about SO, but the docs could be made clearer as it's the first place many devs go to for info.

BTW, most serilog sinks document how to use the code and json options, so I assumed the same for this one. And since there isn't such documentation I panicked - I didn't realise the json config was similar for all sinks. Thanks for explaining that.

The stuff I documented above by trial and error seems to work (except for monitorign), so hopefully it can help others that end up here.

Thanks for maintaining this plugin, it's really great!

@bartelink
Copy link
Member

I am not for one moment debating that it would be great to get more complete examples into the repo:-

that's not to say a PR demonstrating a working config wouldn't work.

In other words, a PR would be really appreciated... You, as someone sitting there with a working config file, who didn't know how to do that until recently, are literally the best placed person on this planet to do that!

Thanks for maintaining this plugin, it's really great

I personally happen to have contributed code to this sink, but am by no means a/the maintainer.

There is an original author, and that author has a day job. It's an open source project, and it's on us to do what we can to make it the best it can be by our collective effort.

@lonix1
Copy link
Author

lonix1 commented Mar 1, 2021

I've never successfully made PRs on github - always seem to mess up. 😋

(I'm an xkcd sort of git user...)

@bartelink
Copy link
Member

While you may be suffering from imposter syndrome, I have full confidence you'd make a much better PR than I would on this - the rest is up to you. (I am also an xkcd git user, I have a very small set of tactics I use, but I always work it out somehow...). Looking forward to seeing the PR ;)

@raheinz57
Copy link

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

3 participants