diff --git a/NzbDrone.Common/LogConfiguration.cs b/NzbDrone.Common/LogConfiguration.cs index 7d09b7203..1770cfe70 100644 --- a/NzbDrone.Common/LogConfiguration.cs +++ b/NzbDrone.Common/LogConfiguration.cs @@ -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) diff --git a/NzbDrone.Update/Program.cs b/NzbDrone.Update/Program.cs index 2c8409f12..0e3ef7dfe 100644 --- a/NzbDrone.Update/Program.cs +++ b/NzbDrone.Update/Program.cs @@ -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(); } diff --git a/NzbDrone.Web.UI.Test/AutomationTestBase.cs b/NzbDrone.Web.UI.Test/AutomationTestBase.cs index bfef1ecde..d6ad7a9ac 100644 --- a/NzbDrone.Web.UI.Test/AutomationTestBase.cs +++ b/NzbDrone.Web.UI.Test/AutomationTestBase.cs @@ -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")) diff --git a/NzbDrone/CentralDispatch.cs b/NzbDrone/CentralDispatch.cs index 3e1f9c60d..ddb8ab6ab 100644 --- a/NzbDrone/CentralDispatch.cs +++ b/NzbDrone/CentralDispatch.cs @@ -43,6 +43,7 @@ namespace NzbDrone private static void InitilizeApp() { + LogConfiguration.RegisterFileLogger("nzbdrone.log"); LogConfiguration.RegisterConsoleLogger(LogLevel.Debug); LogConfiguration.RegisterUdpLogger(); LogConfiguration.RegisterExceptioneer();