mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Tidy up logging renderer
This commit is contained in:
@@ -13,7 +13,6 @@ using Jackett.Common.Services.Interfaces;
|
|||||||
using Jackett.Common.Utils.Clients;
|
using Jackett.Common.Utils.Clients;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NLog.Config;
|
using NLog.Config;
|
||||||
using NLog.LayoutRenderers;
|
|
||||||
using NLog.Targets;
|
using NLog.Targets;
|
||||||
|
|
||||||
namespace Jackett.Common
|
namespace Jackett.Common
|
||||||
@@ -179,7 +178,7 @@ namespace Jackett.Common
|
|||||||
var logFileName = settings.CustomLogFileName ?? "log.txt";
|
var logFileName = settings.CustomLogFileName ?? "log.txt";
|
||||||
var logLevel = settings.TracingEnabled ? LogLevel.Debug : LogLevel.Info;
|
var logLevel = settings.TracingEnabled ? LogLevel.Debug : LogLevel.Info;
|
||||||
// Add custom date time format renderer as the default is too long
|
// Add custom date time format renderer as the default is too long
|
||||||
ConfigurationItemFactory.Default.LayoutRenderers.RegisterDefinition("simpledatetime", typeof(SimpleDateTimeRenderer));
|
ConfigurationItemFactory.Default.LayoutRenderers.RegisterDefinition("simpledatetime", typeof(Utils.LoggingSetup.SimpleDateTimeRenderer));
|
||||||
|
|
||||||
var logConfig = new LoggingConfiguration();
|
var logConfig = new LoggingConfiguration();
|
||||||
var logFile = new FileTarget();
|
var logFile = new FileTarget();
|
||||||
@@ -265,13 +264,4 @@ namespace Jackett.Common
|
|||||||
ConfigService.SaveConfig(ServerConfig);
|
ConfigService.SaveConfig(ServerConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[LayoutRenderer("simpledatetime")]
|
|
||||||
public class SimpleDateTimeRenderer : LayoutRenderer
|
|
||||||
{
|
|
||||||
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
|
|
||||||
{
|
|
||||||
builder.Append(DateTime.Now.ToString("MM-dd HH:mm:ss"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -1,8 +1,12 @@
|
|||||||
using Jackett.Common.Models.Config;
|
using Jackett.Common.Models.Config;
|
||||||
using Jackett.Common.Services;
|
using Jackett.Common.Services;
|
||||||
|
using NLog;
|
||||||
using NLog.Config;
|
using NLog.Config;
|
||||||
|
using NLog.LayoutRenderers;
|
||||||
using NLog.Targets;
|
using NLog.Targets;
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Jackett.Common.Utils
|
namespace Jackett.Common.Utils
|
||||||
{
|
{
|
||||||
@@ -45,5 +49,14 @@ namespace Jackett.Common.Utils
|
|||||||
|
|
||||||
return logConfig;
|
return logConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[LayoutRenderer("simpledatetime")]
|
||||||
|
public class SimpleDateTimeRenderer : LayoutRenderer
|
||||||
|
{
|
||||||
|
protected override void Append(StringBuilder builder, LogEventInfo logEvent)
|
||||||
|
{
|
||||||
|
builder.Append(DateTime.Now.ToString("MM-dd HH:mm:ss"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user