limit console log output on windows (#1212)

This commit is contained in:
Jason Dove
2023-03-16 06:21:02 -05:00
committed by GitHub
parent 7e0801119e
commit fdab54a055
8 changed files with 38 additions and 41 deletions
+18 -3
View File
@@ -1,8 +1,10 @@
using System.Runtime.InteropServices;
using Destructurama;
using ErsatzTV.Core;
using Serilog;
using Serilog.Core;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
namespace ErsatzTV;
@@ -42,13 +44,26 @@ public class Program
{
LoggingLevelSwitch.MinimumLevel = LogEventLevel.Information;
Log.Logger = new LoggerConfiguration()
LoggerConfiguration loggerConfiguration = new LoggerConfiguration()
.ReadFrom.Configuration(Configuration)
.MinimumLevel.ControlledBy(LoggingLevelSwitch)
.Destructure.UsingAttributes()
.Enrich.FromLogContext()
.WriteTo.File(FileSystemLayout.LogFilePath, rollingInterval: RollingInterval.Day)
.CreateLogger();
.WriteTo.File(FileSystemLayout.LogFilePath, rollingInterval: RollingInterval.Day);
// for performance reasons, restrict windows console to error logs
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
loggerConfiguration = loggerConfiguration.WriteTo.Console(
restrictedToMinimumLevel: LogEventLevel.Error,
theme: AnsiConsoleTheme.Code);
}
else
{
loggerConfiguration = loggerConfiguration.WriteTo.Console(theme: AnsiConsoleTheme.Code);
}
Log.Logger = loggerConfiguration.CreateLogger();
try
{
-1
View File
@@ -59,7 +59,6 @@ public class WorkerService : BackgroundService
error.Value));
break;
case DeleteOrphanedArtwork deleteOrphanedArtwork:
_logger.LogInformation("Deleting orphaned artwork from the database");
await mediator.Send(deleteOrphanedArtwork, cancellationToken);
break;
case AddTraktList addTraktList:
-11
View File
@@ -1,19 +1,8 @@
{
"Serilog": {
"Using": [
"Serilog.Sinks.Console"
],
"MinimumLevel": {
"Default": "Debug"
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
-11
View File
@@ -1,8 +1,5 @@
{
"Serilog": {
"Using": [
"Serilog.Sinks.Console"
],
"MinimumLevel": {
"Default": "Information",
"Override": {
@@ -11,14 +8,6 @@
"System.Net.Http.HttpClient": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",