Coder Social home page Coder Social logo

Comments (7)

nblumhardt avatar nblumhardt commented on August 19, 2024 4

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.

kwaazaar avatar kwaazaar commented on August 19, 2024 2

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.

nblumhardt avatar nblumhardt commented on August 19, 2024 1

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.

kwaazaar avatar kwaazaar commented on August 19, 2024

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.

nblumhardt avatar nblumhardt commented on August 19, 2024

Great, glad to hear it's working for you now πŸ‘

from serilog-extensions-logging.

Su-s avatar Su-s commented on August 19, 2024

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 to Information.

Cheers!

from serilog-extensions-logging.

bartelink avatar bartelink commented on August 19, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.