-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Address Serilog documentation issues raised as per #3247 #3254
Conversation
- Address serilog colored console requirement. - Remove requirement for "SerilogLogMessageFormatter" as code examples appear to run without specifying the formatter. - Add an example of how an output template is configured for the extensions demo. - Remove use of serilog application configuration in code from the hocon example, but mention it as a feature of serilog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to keep the big about SerilogMessageFormatter
?
The following example uses Serilogs __Colored Console__ sink available via nuget, there are wide range of other sinks available depending on your needs, for example a rolling log file sink. See serilogs documentation for details on these. | ||
|
||
``` | ||
PM> Install-Package Serilog.Sinks.ColoredConsole |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good
```csharp | ||
var log = Context.GetLogger(new SerilogLogMessageFormatter()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this? Isn't that necessary to get the semantic Serilog-style formatting to work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I found when I ran the examples, that it did not seem to make a difference in output whether the formatter was included or not. I felt if it was not necessary or no longer necessary, it was probably best to remove from the example. It seems allot of this structuring of output is handled in serilog - https://github.com/serilog/serilog/wiki/Structured-Data#default-behaviour - some of this page seems to apply to 2.6.0 but the following seems to apply for 2.5.0
Log.Information("The value is {counter}", counter);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
funnily, the following works too
private void Handle(int count)
{
var log = Context.GetLogger();
log.Info("Count is {a} {b} {c}", count, 2, true);
}
2018-01-08 18:23:12 INF Count is 1 2 True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. The SerilogLogMessageFormatter is no longer needed.
+1 on @stijnherreman comment. And it is exactly the reason why serilog plugins have not been mentioned in the docs. I am not a fan of pointing people to a specific nuget package in this case. Because its an external project, and we don't want to update our docs everytime one of their plugin's moves somewhere else. Mention the plugin/extensions name, sure. But don't specify an exact nuget package, imho. |
If you wish I can replace the colored console with the standard console sink as a sink is necessary for output. I would hope that the console sink would be considered a standard sink. |
Thats also an option. Not sure if the normal console sink is built in though, i never use it :P Either way im ok with either option. |
To the best of my knowledge, one sink is necessary. There own page mention these two packages as part of there basic setup (https://github.com/serilog/serilog/wiki/Getting-Started).
I use console myself mostly for testing, but rolling log file in production, it has nice retention handling built in. |
appear to run without specifying the formatter.
extensions demo.
example, but mention it as a feature of serilog.