1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-25 17:17:02 +00:00

Nzbdrone.exe file logging

This commit is contained in:
kay.one 2011-12-19 11:07:39 -08:00
parent d3f6c685cd
commit 9be08b810e
4 changed files with 42 additions and 12 deletions

View file

@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using NLog; using NLog;
using NLog.Config; using NLog.Config;
using NLog.Targets; 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() public static void RegisterExceptioneer()
{ {
if (EnviromentProvider.IsProduction) if (EnviromentProvider.IsProduction)

View file

@ -62,20 +62,14 @@ private static void TransferUpdateLogs()
private static void InitLoggers() private static void InitLoggers()
{ {
LogConfiguration.RegisterExceptioneer();
LogConfiguration.RegisterConsoleLogger(LogLevel.Trace); LogConfiguration.RegisterConsoleLogger(LogLevel.Trace);
LogConfiguration.RegisterUdpLogger(); LogConfiguration.RegisterUdpLogger();
var lastUpgradeLog = new FileTarget(); var logPath = Path.Combine(new EnviromentProvider().GetSandboxLogFolder(), DateTime.Now.ToString("yyyy.MM.dd-H-mm") + ".txt");
lastUpgradeLog.AutoFlush = true; LogConfiguration.RegisterFileLogger(logPath);
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();
LogConfiguration.Reload(); LogConfiguration.Reload();
} }

View file

@ -113,9 +113,29 @@ private static void CleanBinFolder()
static void StartNzbDrone() 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() public static void StopNzbDrone()
{ {
foreach (var process in Process.GetProcessesByName("nzbdrone")) foreach (var process in Process.GetProcessesByName("nzbdrone"))

View file

@ -43,6 +43,7 @@ private static void BindKernel()
private static void InitilizeApp() private static void InitilizeApp()
{ {
LogConfiguration.RegisterFileLogger("nzbdrone.log");
LogConfiguration.RegisterConsoleLogger(LogLevel.Debug); LogConfiguration.RegisterConsoleLogger(LogLevel.Debug);
LogConfiguration.RegisterUdpLogger(); LogConfiguration.RegisterUdpLogger();
LogConfiguration.RegisterExceptioneer(); LogConfiguration.RegisterExceptioneer();