limit console log output on windows (#1212)
This commit is contained in:
+18
-3
@@ -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
|
||||
{
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user