From 046180fe63939abcc24da65a0825f2eb706fd3d3 Mon Sep 17 00:00:00 2001 From: SocksOnHead Date: Sat, 27 Sep 2025 20:59:34 +0200 Subject: [PATCH] feat: Add serilog (#5) --- .github/workflows/build.yml | 16 ++++++++++++++++ HomeApi/HomeApi.csproj | 4 ++++ HomeApi/Program.cs | 8 ++++++-- HomeApi/appsettings.Development.json | 8 ++++++++ HomeApi/appsettings.json | 8 ++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9872aba..8ae6f31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -124,6 +124,14 @@ jobs: "Microsoft.AspNetCore" = "Warning" } } + Seq = @{ + ServerUrl = "https://log.azaaxin.com" + ApiKey = "KEY" + MinimumLevel = "Trace" + LevelOverride = @{ + Microsoft: "Warning" + } + } ApiConfiguration = @{ EspConfiguration = @{ InformationBoardImageUrl = "http://server_ip:port/home/default.jpg" @@ -178,6 +186,14 @@ jobs: "Microsoft.AspNetCore" = "Warning" } } + Seq = @{ + ServerUrl = ${{ vars.SEQ_URL }} + ApiKey = ${{ secrets.seq_api_key }} + MinimumLevel = "Trace" + LevelOverride = @{ + Microsoft: "Warning" + } + } ApiConfiguration = @{ EspConfiguration = @{ InformationBoardImageUrl = "${{ vars.ESP_IMAGE_URL }}" diff --git a/HomeApi/HomeApi.csproj b/HomeApi/HomeApi.csproj index 23610eb..170408b 100644 --- a/HomeApi/HomeApi.csproj +++ b/HomeApi/HomeApi.csproj @@ -17,6 +17,7 @@ + @@ -30,5 +31,8 @@ Always + + Always + diff --git a/HomeApi/Program.cs b/HomeApi/Program.cs index 5482fb1..e8dfd07 100644 --- a/HomeApi/Program.cs +++ b/HomeApi/Program.cs @@ -1,8 +1,12 @@ using HomeApi.Registration; using Scalar.AspNetCore; +using Serilog; var builder = WebApplication.CreateBuilder(args); - +builder.Services.AddLogging(loggingBuilder => +{ + loggingBuilder.AddSeq(builder.Configuration.GetSection("Seq")); +}); builder.Services.AddHttpClient(); builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining()); builder.Services.AddControllers(); @@ -22,4 +26,4 @@ app.UseAuthorization(); app.MapControllers(); -app.Run(); \ No newline at end of file +app.Run(); diff --git a/HomeApi/appsettings.Development.json b/HomeApi/appsettings.Development.json index c288e85..b70be38 100644 --- a/HomeApi/appsettings.Development.json +++ b/HomeApi/appsettings.Development.json @@ -12,6 +12,14 @@ "Microsoft.AspNetCore": "Warning" } }, + "Seq": { + "ServerUrl": "https://log.azaaxin.com", + "ApiKey": "KEY", + "MinimumLevel": "Trace", + "LevelOverride": { + "Microsoft": "Warning" + } + }, "ApiConfiguration": { "EspConfiguration": { "InformationBoardImageUrl": "http://192.168.101.178:5000/home/default.jpg", diff --git a/HomeApi/appsettings.json b/HomeApi/appsettings.json index c288e85..b70be38 100644 --- a/HomeApi/appsettings.json +++ b/HomeApi/appsettings.json @@ -12,6 +12,14 @@ "Microsoft.AspNetCore": "Warning" } }, + "Seq": { + "ServerUrl": "https://log.azaaxin.com", + "ApiKey": "KEY", + "MinimumLevel": "Trace", + "LevelOverride": { + "Microsoft": "Warning" + } + }, "ApiConfiguration": { "EspConfiguration": { "InformationBoardImageUrl": "http://192.168.101.178:5000/home/default.jpg",