mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-25 01:02:05 +00:00
Nzbdrone.exe file logging
This commit is contained in:
parent
d3f6c685cd
commit
9be08b810e
4 changed files with 42 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
|
@ -74,6 +75,20 @@ public static void RegisterUdpLogger()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
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 @@ private static void TransferUpdateLogs()
|
|||
|
||||
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}";
|
||||
var logPath = Path.Combine(new EnviromentProvider().GetSandboxLogFolder(), DateTime.Now.ToString("yyyy.MM.dd-H-mm") + ".txt");
|
||||
LogConfiguration.RegisterFileLogger(logPath);
|
||||
|
||||
LogManager.Configuration.AddTarget(lastUpgradeLog.GetType().Name, lastUpgradeLog);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, lastUpgradeLog));
|
||||
|
||||
LogConfiguration.RegisterExceptioneer();
|
||||
LogConfiguration.Reload();
|
||||
}
|
||||
|
||||
|
|
|
@ -113,9 +113,29 @@ private static void CleanBinFolder()
|
|||
|
||||
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 @@ private static void BindKernel()
|
|||
|
||||
private static void InitilizeApp()
|
||||
{
|
||||
LogConfiguration.RegisterFileLogger("nzbdrone.log");
|
||||
LogConfiguration.RegisterConsoleLogger(LogLevel.Debug);
|
||||
LogConfiguration.RegisterUdpLogger();
|
||||
LogConfiguration.RegisterExceptioneer();
|
||||
|
|
Loading…
Reference in a new issue