mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 11:14:27 +00:00
Add Serilog file sink configuration and update package references
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
<PackageReference Include="Serilog"/>
|
||||
<PackageReference Include="Serilog.Extensions.Logging"/>
|
||||
<PackageReference Include="Serilog.Sinks.Console"/>
|
||||
<PackageReference Include="Serilog.Sinks.File"/>
|
||||
<PackageReference Include="Serilog.Sinks.SyslogMessages"/>
|
||||
<PackageReference Include="WebStoating.Markdig.PrismWithPlugins"/>
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql"/>
|
||||
|
||||
@@ -80,6 +80,27 @@ builder.Logging.AddSerilog(new LoggerConfiguration().WriteTo
|
||||
restrictedToMinimumLevel: LogEventLevel.Information)
|
||||
.CreateLogger());
|
||||
|
||||
IConfigurationSection logFileSection = builder.Configuration.GetSection("Serilog:File");
|
||||
|
||||
builder.Logging.AddSerilog(new LoggerConfiguration().WriteTo.File(logFileSection["Path"] ?? "logs/log.txt",
|
||||
fileSizeLimitBytes:
|
||||
long.TryParse(logFileSection["FileSizeLimitBytes"],
|
||||
out long sizeLimit)
|
||||
? sizeLimit
|
||||
: 10 * 1024 * 1024,
|
||||
rollingInterval:
|
||||
Enum.TryParse(logFileSection["RollingInterval"],
|
||||
out RollingInterval interval)
|
||||
? interval
|
||||
: RollingInterval.Day,
|
||||
rollOnFileSizeLimit: true,
|
||||
retainedFileCountLimit:
|
||||
int.TryParse(logFileSection["MaxRetainedFiles"],
|
||||
out int maxFiles)
|
||||
? maxFiles
|
||||
: 31)
|
||||
.CreateLogger());
|
||||
|
||||
builder.Logging.AddSerilog(new LoggerConfiguration().WriteTo
|
||||
.Sentry("https://0bdaf61514c94d74c3c8c7d1cbba999f@sentry.claunia.com/2",
|
||||
LogEventLevel.Debug,
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
"DefaultConnection": "DataSource=Data\\app.db;Cache=Shared"
|
||||
},
|
||||
"Logging": {
|
||||
"LogFile": {
|
||||
"Path": "/var/log/aaru-server/aaru-server.log",
|
||||
"RollingInterval": "Day",
|
||||
"FileSizeLimitBytes": 10485760,
|
||||
"MaxRetainedFiles": 7,
|
||||
"RetainedDays": 30
|
||||
},
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<PackageVersion Include="Serilog" Version="4.3.0"/>
|
||||
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.2"/>
|
||||
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0"/>
|
||||
<PackageVersion Include="Serilog.Sinks.File" Version="7.0.0"/>
|
||||
<PackageVersion Include="Serilog.Sinks.SyslogMessages" Version="4.0.0"/>
|
||||
<PackageVersion Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31"/>
|
||||
<PackageVersion Include="Text.Analyzers" Version="4.14.0"/>
|
||||
|
||||
Reference in New Issue
Block a user