Skip to content

Possible Reloadable Logger Issue #39

Closed
@simbaja

Description

@simbaja

I've got .netcore31 application (both a generic host and ASP.NET) application where a logger is throwing an exception when using the reloadable logger. I haven't developed a minimum test case, but it may have to do with static loggers being accessed early in the lifetime. The pattern is as follows:

  1. Create a class with a static logger (private static ILogger _log = Log.ForContext();
  2. Add another static method/property to the class, call a log method (i.e. _log.Debug) in the method.
  3. Add a non-static method that calls three log methods (i.e. _log.Debug x3)
  4. During services initialization, call the static method
  5. Initialize the CreateBootstrapLogger/UseSerilog as normal
  6. In the worker, get an instance of the class and call the non-static method.
  7. The first log method will succeed, as will the second
  8. The third throws an exception, because _cached is somehow null but _frozen is true (so it's trying to directly call the _cached logger)

If I get some time, I'll try to get a minimum reproducible example written, but I'm under some tight work deadlines at the moment. Hopefully the description above will help find the logic issue. Presumably, _cached = null and _frozen = true should never happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions