Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Logging debug output with Serilog #155

Closed
@MV10

Description

@MV10

Here's a note for your Logging topic in your wiki about how to set up Serilog. It doesn't normally work with LoggerFactory the way older loggers do (I used to be a frequent Serilog contributor), so it's kind of hard to track down how this is done because one of the packages has been mostly superseded by builder-helpers in other packages. The dependencies are Microsoft.Extensions.Logging, Serilog.Extensions.Logging, and Serilog.Sinks.File.

There are many other possible approaches, but at a minimum this gets the job done:

if (useDebug)
{
    File.Delete("debug.log"); // log output will append
    MMALCameraConfig.Debug = true;
    MMALLog.LoggerFactory = new LoggerFactory()
        .AddSerilog(new LoggerConfiguration()
            .MinimumLevel.Verbose()
            .WriteTo.File("debug.log")
            .CreateLogger());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions