1

I am trying to understand why my application does not log the same number of informations when executed from visual studio and/or under IIS.

This is my startup code (constructor) related to logging:

Log.Logger = new LoggerConfiguration()
    .ReadFrom.Configuration( Configuration )
    .CreateLogger();

and then in Configure method

public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory ) {
    loggerFactory.AddSerilog();

}

here finally you can find an extract of the appsettings.json configuration file

"Serilog": {
    "Using": [ "Serilog.Sinks.RollingFile" ],
    "MinimumLevel": {
        "Default": "Verbose",
        "Override": {
            "Microsoft": "Error",
            "Microsoft.AspNetCore.Identity": "Debug",
            "IdentityServer4": "Verbose",
            "IdentityModel": "Verbose",
            "System": "Warning",
            "Serilog": "Verbose"
        }
    },
    "WriteTo": [
        {
            "Name": "RollingFile",
            "Args": {
                "pathFormat": "AppLogs/logger-{Date}.log",
                "outputTemplate": "{Timestamp:o} [{Level:u3}] ({Application}/{MachineName}/{ThreadId}) {Message}{NewLine}{Exception}",
                "fileSizeLimitBytes": 16384
            }
        },
        {
            "Name": "LiterateConsole"
        }
    ],
    "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
    "Properties": {
        "Application": "Sample"
    }
},

The log file is created but the information inside the file is not the same as the ones I can see in the console output. What does I am missing?

Nkosi
  • 235,767
  • 35
  • 427
  • 472
Lorenzo
  • 29,081
  • 49
  • 125
  • 222
  • 1
    Hi Lorenzo - if you're using ASP.NET Core 2.0, `UseSerilog()` is recommended over the older `AddSerilog()`; see https://github.com/serilog/serilog-aspnetcore for info. HTH! – Nicholas Blumhardt Oct 24 '17 at 23:55
  • Thanks a lot @NicholasBlumhardt. Did'nt know this new package. If you want to write the suggestion as an answer I will be glad to mark it as answered. – Lorenzo Oct 25 '17 at 15:18

0 Answers0