File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44using Serilog . Exceptions ;
55using Serilog . Exceptions . Core ;
66using Serilog . Exceptions . EntityFrameworkCore . Destructurers ;
7+ using Serilog . Sinks . Grafana . Loki ;
78
89namespace SerilogTest ;
910
@@ -37,6 +38,8 @@ private static async Task Main(string[] args)
3738
3839 var builder = WebApplication . CreateBuilder ( args ) ;
3940
41+ _ = builder . Logging . ClearProviders ( ) ;
42+
4043 // Add services to the container.
4144 _ = builder . Host
4245 . UseSerilog (
@@ -129,7 +132,9 @@ static LoggerConfiguration ConfigureLogger(LoggerConfiguration configuration)
129132 . WithExceptionDetails (
130133 new DestructuringOptionsBuilder ( ) . WithDefaultDestructurers ( )
131134 . WithIgnoreStackTraceAndTargetSiteExceptionFilter ( )
132- . WithDestructurers ( [ new DbUpdateExceptionDestructurer ( ) ] ) ) ;
135+ . WithDestructurers ( [ new DbUpdateExceptionDestructurer ( ) ] ) )
136+ . WriteTo
137+ . GrafanaLoki ( "http://localhost:3100" ) ;
133138 }
134139 }
135140
Original file line number Diff line number Diff line change 2222 <PackageReference Include =" Serilog.Exceptions.EntityFrameworkCore" Version =" 8.4.0" />
2323 <PackageReference Include =" Serilog.Sinks.Async" Version =" 2.1.0" />
2424 <PackageReference Include =" Microsoft.Extensions.Logging.Abstractions" Version =" 9.0.4" />
25+ <PackageReference Include =" Serilog.Sinks.Grafana.Loki" Version =" 8.3.0" />
2526 </ItemGroup >
2627
2728 <ItemGroup >
You can’t perform that action at this time.
0 commit comments