How do I use Serilog.enrichers.HttpContextInfo from a class library referencing a web project?

0

I have a solution with a very funky setup blending Classic ASP / MVC. Thing is, I can't get Serilog.enrichers.HttpContextInfo to work in this setup.

The error is:

Could not load file or assembly 'Serilog.Enrichers.HttpContextInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

Here's some pertinent code: (there's obviously more code, but this is relevant)

Startup.cs

 private LoggingLevelSwitch _levelSwitch = new LoggingLevelSwitch();
 // ....more logic to determine level and get IP to SEQ....

        // create the logger
        Log.Logger = new LoggerConfiguration()
            .Enrich.WithRequest()
          .MinimumLevel.ControlledBy(_levelSwitch)
          .WriteTo.Seq(seqIp)
          .CreateLogger();

Then in a controller:

try
{
    int x = 0;
    int y = 5;
    Log.Warning("SERI - Dividing {x} by {y}", new object[] { x, y });
    int z = y / x;
}
catch (Exception ex)
{
    // this method overload seems weird
    Log.Fatal(ex, "SERI - {exMessage} - {moreInfoArray}", ex.Message, new object[] { Environment.MachineName });
}

What could be missing?

c#
asp.net-mvc
logging
serilog
asked on Stack Overflow Oct 23, 2017 by Beau D'Amore • edited Nov 13, 2017 by Alexey Subach

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0