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

Updated from 2.5.0 to 2.6.0 broke my project. #91

Closed
VictorioBerra opened this issue Mar 15, 2018 · 6 comments
Closed

Updated from 2.5.0 to 2.6.0 broke my project. #91

VictorioBerra opened this issue Mar 15, 2018 · 6 comments
Labels

Comments

@VictorioBerra
Copy link

Asp.Net Core

Error: System.InvalidOperationException: 'No LoggingLevelSwitch has been declared with name "Debug". You might be missing a section "LevelSwitches":{"Debug":"InitialLevel"}'

.UseSerilog((hostingContext, loggerConfiguration) => {
    loggerConfiguration.ReadFrom.Configuration(hostingContext.Configuration);
});
  "Serilog": {
    "MinimumLevel": {
      "Default": "Debug",
      "Override": {
        "Microsoft": "Warning",
        "System": "Warning",
        "Microsoft.AspNetCore.Authentication": "Information"
      }
    },
    "WriteTo:ConsoleSublogger": {
      "Name": "Logger",
      "Args": {
        "configureLogger": {
          "WriteTo": [
            {
              "Name": "LiterateConsole",
              "Args": {
                "outputTemplate": "DevConf [{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}"
              }
            }
          ]
        },
        "restrictedToMinimumLevel": "Debug"
      }
    },
    "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
    "Properties": {
      "Application": "WashuIdentityServer"
    }
  },

I dont see anywhere that I tell it to use a switch. Also, I dont see this on the README and I don't see it in the samples.

@VictorioBerra
Copy link
Author

Yeah, you cant even run the sample app now.

git clone https://github.com/serilog/serilog-settings-configuration.git
cd .\sample\Sample
dotnet run --framework netcoreapp1.0

It appears the code thinks a level switch is required now.

@nblumhardt
Copy link
Member

Thanks for the heads-up, Victorio. Taking a look now 👍

nblumhardt added a commit to nblumhardt/serilog-settings-configuration that referenced this issue Mar 15, 2018
nblumhardt added a commit that referenced this issue Mar 15, 2018
Fix #91 - wrong parameter name on surrogate WriteTo.Logger configuration method
@nblumhardt
Copy link
Member

The issue here was a parameter name mismatch in the code that handles the WriteTo.Logger special case. It's fixed in #92.

2.6.1 is now on NuGet with a fix (it may take up to an hour for NuGet to index it).

@VictorioBerra if you can check that the new version works for you, that would be great.

Leaving this open as the fix needs to come back into dev, and there's some minor tidying up to do after a hasty fix :-)

@VictorioBerra
Copy link
Author

@nblumhardt Your quick response time and fix is greatly appreciated. Thanks a lot!

@nblumhardt
Copy link
Member

Thanks Victorio 👍

Just reopening briefly until we've finished bringing the changes back onto dev.

@nblumhardt nblumhardt reopened this Mar 15, 2018
@tsimbalar
Copy link
Member

Here are 2 tests that fail in dev (when added to class ConfigurationSettingsTests) ...

[Trait("Bugfix", "#91")]
[Fact]
public void WriteToLoggerWithRestrictedToMinimumLevelIsSupported()
{
    var json = @"{
        ""Serilog"": {            
            ""Using"": [""TestDummies""],
            ""WriteTo"": [{
                ""Name"": ""Logger"",
                ""Args"": {
                    ""configureLogger"" : {
                        ""WriteTo"": [{
                            ""Name"": ""DummyRollingFile"",
                            ""Args"": {""pathFormat"" : ""C:\\""}
                        }]},
                    ""restrictedToMinimumLevel"": ""Warning"" 
                }
            }]        
        }
    }";

    var log = ConfigFromJson(json)
        .CreateLogger();

    DummyRollingFileSink.Emitted.Clear();

    log.Write(Some.InformationEvent());
    log.Write(Some.WarningEvent());

    Assert.Equal(1, DummyRollingFileSink.Emitted.Count);
}

[Trait("Bugfix", "#91")]
[Fact]
public void WriteToLoggerWithLevelSwitchIsSupported()
{
    var json = @"{
        ""Serilog"": {            
            ""Using"": [""TestDummies""],
            ""LevelSwitches"": {""$subLoggerSwitch"" : ""Warning"" },
            ""WriteTo"": [{
                ""Name"": ""Logger"",
                ""Args"": {
                    ""configureLogger"" : {
                        ""WriteTo"": [{
                            ""Name"": ""DummyRollingFile"",
                            ""Args"": {""pathFormat"" : ""C:\\""}
                        }]},
                    ""restrictedToMinimumLevel"": ""$subLoggerSwitch"" 
                }
            }]        
        }
    }";

    var log = ConfigFromJson(json)
        .CreateLogger();

    DummyRollingFileSink.Emitted.Clear();

    log.Write(Some.InformationEvent());
    log.Write(Some.WarningEvent());

    Assert.Equal(1, DummyRollingFileSink.Emitted.Count);
}

The second one still fails on master, so I'm not too sure whether the fix is complete ... (I'm having issue with a brand new install of Visual Studio on a new machine, so there might be false positives ...)

@tsimbalar tsimbalar added the bug label Mar 19, 2018
merbla added a commit to merbla/serilog-settings-configuration that referenced this issue Apr 5, 2018
@merbla merbla mentioned this issue Apr 5, 2018
@merbla merbla mentioned this issue May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants