mirror of
https://github.com/Radarr/Radarr
synced 2024-12-26 01:38:24 +00:00
fixed issue where method names weren't being logged to database.
This commit is contained in:
parent
0ee175e382
commit
df38aa2307
1 changed files with 6 additions and 8 deletions
|
@ -1,13 +1,14 @@
|
|||
using System;
|
||||
using NLog.Config;
|
||||
using NLog;
|
||||
using NLog.Layouts;
|
||||
using NLog.Targets;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Instrumentation
|
||||
{
|
||||
|
||||
public class DatabaseTarget : Target
|
||||
public class DatabaseTarget : TargetWithLayout
|
||||
{
|
||||
private readonly ILogRepository _repository;
|
||||
|
||||
|
@ -18,9 +19,10 @@ public DatabaseTarget(ILogRepository repository)
|
|||
|
||||
public void Register()
|
||||
{
|
||||
Layout = new SimpleLayout("${callsite:className=false:fileName=false:includeSourcePath=false:methodName=true}");
|
||||
|
||||
LogManager.Configuration.AddTarget("DbLogger", this);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, this));
|
||||
|
||||
LogManager.ConfigurationReloaded += (sender, args) => Register();
|
||||
}
|
||||
|
||||
|
@ -30,11 +32,7 @@ protected override void Write(LogEventInfo logEvent)
|
|||
var log = new Log();
|
||||
log.Time = logEvent.TimeStamp;
|
||||
log.Message = logEvent.FormattedMessage;
|
||||
|
||||
if (logEvent.UserStackFrame != null)
|
||||
{
|
||||
log.Method = logEvent.UserStackFrame.GetMethod().Name;
|
||||
}
|
||||
log.Method = Layout.Render(logEvent);
|
||||
|
||||
log.Logger = logEvent.LoggerName;
|
||||
|
||||
|
|
Loading…
Reference in a new issue