mirror of https://github.com/Radarr/Radarr
Nzbdrone.exe file logging
This commit is contained in:
parent
d3f6c685cd
commit
9be08b810e
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
|
@ -74,6 +75,20 @@ namespace NzbDrone.Common
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static void RegisterFileLogger(string fileName)
|
||||
{
|
||||
var fileTarget = new FileTarget();
|
||||
fileTarget.AutoFlush = true;
|
||||
fileTarget.ConcurrentWrites = false;
|
||||
fileTarget.FileName = fileName;
|
||||
fileTarget.KeepFileOpen = false;
|
||||
fileTarget.Layout = "${longdate} - ${logger}: ${message} ${exception:format=ToString}";
|
||||
|
||||
LogManager.Configuration.AddTarget(fileTarget.GetType().Name, fileTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, fileTarget));
|
||||
}
|
||||
|
||||
public static void RegisterExceptioneer()
|
||||
{
|
||||
if (EnviromentProvider.IsProduction)
|
||||
|
|
|
@ -62,20 +62,14 @@ namespace NzbDrone.Update
|
|||
|
||||
private static void InitLoggers()
|
||||
{
|
||||
LogConfiguration.RegisterExceptioneer();
|
||||
|
||||
LogConfiguration.RegisterConsoleLogger(LogLevel.Trace);
|
||||
LogConfiguration.RegisterUdpLogger();
|
||||
|
||||
var lastUpgradeLog = new FileTarget();
|
||||
lastUpgradeLog.AutoFlush = true;
|
||||
lastUpgradeLog.ConcurrentWrites = false;
|
||||
lastUpgradeLog.FileName = Path.Combine(new EnviromentProvider().GetSandboxLogFolder(), DateTime.Now.ToString("yyyy.MM.dd-H-mm") + ".txt");
|
||||
lastUpgradeLog.KeepFileOpen = false;
|
||||
lastUpgradeLog.Layout = "${longdate} - ${logger}: ${message} ${exception:format=ToString}";
|
||||
|
||||
LogManager.Configuration.AddTarget(lastUpgradeLog.GetType().Name, lastUpgradeLog);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, lastUpgradeLog));
|
||||
|
||||
LogConfiguration.RegisterExceptioneer();
|
||||
var logPath = Path.Combine(new EnviromentProvider().GetSandboxLogFolder(), DateTime.Now.ToString("yyyy.MM.dd-H-mm") + ".txt");
|
||||
LogConfiguration.RegisterFileLogger(logPath);
|
||||
|
||||
LogConfiguration.Reload();
|
||||
}
|
||||
|
||||
|
|
|
@ -113,9 +113,29 @@ namespace NzbDrone.Web.UI.Automation
|
|||
|
||||
static void StartNzbDrone()
|
||||
{
|
||||
Process.Start(Path.Combine(testFolder, "nzbdrone.exe"));
|
||||
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = Path.Combine(testFolder, "nzbdrone.exe"),
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false
|
||||
};
|
||||
|
||||
var nzbDroneProcess = new Process
|
||||
{
|
||||
StartInfo = startInfo
|
||||
};
|
||||
nzbDroneProcess.OutputDataReceived +=
|
||||
delegate(object o, DataReceivedEventArgs args)
|
||||
{
|
||||
Console.WriteLine(args.Data);
|
||||
};
|
||||
|
||||
nzbDroneProcess.Start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void StopNzbDrone()
|
||||
{
|
||||
foreach (var process in Process.GetProcessesByName("nzbdrone"))
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace NzbDrone
|
|||
|
||||
private static void InitilizeApp()
|
||||
{
|
||||
LogConfiguration.RegisterFileLogger("nzbdrone.log");
|
||||
LogConfiguration.RegisterConsoleLogger(LogLevel.Debug);
|
||||
LogConfiguration.RegisterUdpLogger();
|
||||
LogConfiguration.RegisterExceptioneer();
|
||||
|
|
Loading…
Reference in New Issue