Comments (7)
Thanks for the repro, appreciate you taking the time to put this together π
The problem is that Serilog's minimum level is set at the logger level, so you need to add MinimumLevel.Verbose()
to the configuration:
var configuration = new LoggerConfiguration()
.MinimumLevel.Verbose() // This line
.Enrich.WithProperty("servername", Environment.MachineName)
.WriteTo.ColoredConsole(outputTemplate: "SERILOG: [{Level}]: {Message}{NewLine}"); // Specific template, to make it stand out on the console
loggerFactory.AddSerilog(configuration.CreateLogger());
restrictedToMinimumLevel
on the individual sinks will "quieten down" a particular sink, but won't affect the overall level, which defaults to Information
.
Cheers!
from serilog-extensions-logging.
This behaviour does not exist in the MS-stuff, since the sink itself specifies the level. That's what caused the confusion. Thanks for the feedback. I corrected my repro and now it works as expected! π
from serilog-extensions-logging.
Thanks for getting in touch. Trace and Verbose are already treated as synonyms here: https://github.com/serilog/serilog-extensions-logging/blob/dev/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLogger.cs#L125
Do you have a snippet that demonstrates where things are going wrong? Thanks!
from serilog-extensions-logging.
I noticed that code, but it really doesn't work for loglevels Debug and Trace. I created a small repro here: https://github.com/kwaazaar/Serilog.LogLevelRepro
from serilog-extensions-logging.
Great, glad to hear it's working for you now π
from serilog-extensions-logging.
Are there any way to resolve the issue
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [correlationId: {CorrelationId} machineName:{MachineName} environmentName:{EnvironmentName} environmentUserName:{EnvironmentUserName} clientIp:{ClientIp} clientAgent:{ClientAgent} processId:{ProcessId} processName:{ProcessName} memory:{MemoryUsage} level:{Level: u3}] ({SourceContext}) {Message} {NewLine} {Exception} {Properties:j}{NewLine}",
"theme": "Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme::Literate, Serilog.Sinks.Console",
"restrictedToMinimumLevel": "Information"
}
},
{
"Name": "File",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [correlationId: {CorrelationId} machineName:{MachineName} environmentName:{EnvironmentName} environmentUserName:{EnvironmentUserName} clientIp:{ClientIp} clientAgent:{ClientAgent} processId:{ProcessId} processName:{ProcessName} memory:{MemoryUsage} level:{Level: u3}] ({SourceContext}) {Message} {NewLine} {Exception} {Properties:j}{NewLine}",
"path": "%localappdata%\\weabb.log",
"rollingInterval": "Day",
"restrictedToMinimumLevel": "Verbose"
}
},
{
"Name": "Seq",
"Args": {
"serverUrl": "http://localhost:5341",
"apiKey": "none",
"restrictedToMinimumLevel": "Information"
}
}
],
here, I only have to log the verbose details inside file log. and the information level log in seq and console.
is it possible to give like this?
i think this follows the above reply by @nblumhardt.
also, i have updated the logger config like this
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.Destructure.ByTransforming<UserIdentity>(u => new { u.Id, u.UserName })
.CreateBootstrapLogger();
Thanks for the repro, appreciate you taking the time to put this together π
The problem is that Serilog's minimum level is set at the logger level, so you need to add
MinimumLevel.Verbose()
to the configuration:var configuration = new LoggerConfiguration() .MinimumLevel.Verbose() // This line .Enrich.WithProperty("servername", Environment.MachineName) .WriteTo.ColoredConsole(outputTemplate: "SERILOG: [{Level}]: {Message}{NewLine}"); // Specific template, to make it stand out on the console loggerFactory.AddSerilog(configuration.CreateLogger());
restrictedToMinimumLevel
on the individual sinks will "quieten down" a particular sink, but won't affect the overall level, which defaults toInformation
.Cheers!
from serilog-extensions-logging.
@Su-s It's recommended to post question issues on stack overflow rather than necro-posting on 7 year old issues - the issues system here is for new feature work and things like bugs with full repros that can only be solved by maintainers and code changes.
There are way more eyes that will see the question over there tan here; anyone that's going to know the answer and have to time to respond, will also be monitoring the SO serilog
tag.
from serilog-extensions-logging.
Related Issues (20)
- AWSSeriLog not working with Maui Blazor App HOT 1
- No exceptions emitted when generated by faulty audit log configuration HOT 4
- Upgrade codebase HOT 2
- Serilog keeps throwing ArgumentNullException HOT 10
- Add API approval test
- Could not load file or assembly 'Microsoft.Extensions.Logging, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' HOT 2
- Serilog.Extensions.Logging 7.0.0 has a .NET 6.0 TFM with dependencies on 7.0 HOT 3
- Serilog.Extensions.Logging v7 .net6 requires v7 Microsoft.Extensions.Logging pkg
- Unit tests fail when run for .Net Framework HOT 2
- SerilogLogger.cs - Always calls formatter with the Exception parameter as null HOT 1
- SerilogLogger.cs: PrepareWrite Method not found Serilog.Events.LogEvent..ctor HOT 3
- Serilog .NET 8 Windows Service (worker) using BackgroundService Log file not found HOT 2
- Pass-through of `M.E.L.ILogger.BeginScope()` when using custom MEL `ILoggingProvider` as Serilog sink? HOT 5
- Avoid boxing of TState HOT 6
- M.E.L. Log category support exists but is non-obvious on how to include it in text sinks
- Support ActivityTrackingOptions to enrich logs with Activity tags and baggage HOT 5
- Collision with Microsoft.Extensions.Telemetry HOT 1
- `ISupportExternalScope` enrichment HOT 4
- String Quoting - global disable switch HOT 8
- Serilog ignores dotnet logging configuration HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serilog-extensions-logging.