Skip to content

SerilogLoggerProvider should dispose the associated logger, if set #41

@nblumhardt

Description

@nblumhardt

Via: http://stackoverflow.com/questions/38286140/how-to-dispose-of-serilog-2-0-correctly-in-asp-net-core-application

If the provider is using the static Log pipeline, the application should be responsible for disposal as there's no indication of any ownership transfer.

If a disposable Logger instance is passed in, disposing it is reasonable. To make this explicit, we could:

  1. overload AddSerilog() with a method specifically accepting Logger
  2. or, make the overload generic where TLogger: ILogger, IDisposable
  3. or, add a dispose: default Boolean parameter to AddSerilog()
  4. or, add a new method like AddSerilogAndDispose() for the purpose.

The decision here depends on whether we want to move towards disposing by default (1 or 2) or not (3 or 4).

If we want to dispose by default, (1) is probably the friendliest option, while (3) seems like the tidiest opt-in mechanism.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions