/PackZero.Logging

serilog extension for the exception handling

Primary LanguageC#MIT LicenseMIT

Nuget CodeQL MIT

PackZero.Logging

Serilog extension for the exception handling

How to Use

using PackZero.Logging;

exception format is {logType}: {Message} {StackTrace} {Source} {InnerMessage} {InnerStackTrace} {InnerSource} {ExceptionNote}

public class AppHostedService : IHostedService
{
    private readonly ILogger<AppHostedService> logger;

    public AppHostedService(ILogger<AppHostedService> logger)
    {
        this.logger = logger;
    }
    public async Task StartAsync(CancellationToken cancellationToken)
    {
        try
        {
            //actions
        }
        catch (Exception e)
        {
            logger.Exception(e);
        }
    }
}

Features

  • IHostBuilder extension named UseAppZeroLogging() extends ConfigureLogging() and overrides Serilog LoggerConfiguration using internally UseSerilog()
  • Application Name and Environment information will be added as property on Serilo