https://github.com/msx752/packzero.logging
serilog extension for the exception handling
https://github.com/msx752/packzero.logging
Last synced: over 1 year ago
JSON representation
serilog extension for the exception handling
- Host: GitHub
- URL: https://github.com/msx752/packzero.logging
- Owner: msx752
- License: mit
- Created: 2023-02-26T20:07:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-26T20:51:32.000Z (over 3 years ago)
- Last Synced: 2025-03-19T13:11:18.699Z (over 1 year ago)
- Language: C#
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/PackZero.Logging)
[](https://github.com/msx752/PackZero.Logging/actions/workflows/codeql.yml)
[](https://github.com/msx752/PackZero.Logging/blob/main/LICENSE.md)
# PackZero.Logging
Serilog extension for the exception handling
# How to Use
``` c#
using PackZero.Logging;
```
exception format is `{logType}: {Message} {StackTrace} {Source} {InnerMessage} {InnerStackTrace} {InnerSource} {ExceptionNote}`
``` c#
public class AppHostedService : IHostedService
{
private readonly ILogger logger;
public AppHostedService(ILogger 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