feat: Add serilog (#5)

This commit is contained in:
2025-09-27 20:59:34 +02:00
committed by Myx
parent 48f7065a9a
commit 046180fe63
5 changed files with 42 additions and 2 deletions

View File

@@ -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 }}"

View File

@@ -17,6 +17,7 @@
<PackageReference Include="RazorLight" Version="2.3.1" />
<PackageReference Include="Refit.HttpClientFactory" Version="8.0.0" />
<PackageReference Include="Scalar.AspNetCore" Version="2.5.6" />
<PackageReference Include="Seq.Extensions.Logging" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
@@ -30,5 +31,8 @@
<Content Include="wwwroot\index.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="..\.github\workflows\build.yml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@@ -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<Program>());
builder.Services.AddControllers();

View File

@@ -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",

View File

@@ -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",