diff --git a/Log4ViewConfig.l4v b/Log4ViewConfig.l4v
new file mode 100644
index 000000000..4840586f0
--- /dev/null
+++ b/Log4ViewConfig.l4v
@@ -0,0 +1,696 @@
+
+
+ 1
+
+
+ ALL
+
+ false
+ true
+ true
+ true
+ false
+
+ OFF
+
+ 15
+ <_charts z:Id="6" z:Size="0" />
+ <_columns z:Id="7" z:Size="28">
+
+
+ 46
+
+ ClipRight
+ Id
+
+ -1
+ 45
+ 16
+
+
+
+ 47
+
+ ClipRight
+ OriginalTime
+
+ -1
+ 120
+ 16
+
+
+
+ 48
+
+ ClipRight
+ Time
+
+ 1
+ 80
+ 16
+
+
+
+ 49
+
+ ClipRight
+ LocalTime
+
+ -1
+ 120
+ 16
+
+
+
+ 50
+
+ ClipRight
+ UtcTime
+
+ -1
+ 120
+ 16
+
+
+
+ 51
+
+ ClipRight
+ Key
+
+ -1
+ 120
+ 16
+
+
+
+ 52
+
+ ClipRight
+ Level
+
+ -1
+ 85
+ 16
+
+
+
+ 53
+
+ ClipMiddle
+ Logger
+
+ 2
+ 120
+ 16
+
+
+
+ 54
+
+ ClipRight
+ Source
+
+ -1
+ 90
+ 16
+
+
+
+ 55
+
+ ClipRight
+ Message
+
+ 3
+ 320
+ 16
+
+
+
+ 56
+
+ ClipRight
+ Thread
+
+ -1
+ 95
+ 16
+
+
+
+ 57
+
+ ClipRight
+ Host
+
+ -1
+ 90
+ 16
+
+
+
+ 58
+
+ ClipRight
+ Exception
+
+ -1
+ 120
+ 16
+
+
+
+ 59
+
+ ClipRight
+ Domain
+
+ -1
+ 90
+ 16
+
+
+
+ 60
+
+ ClipRight
+ Identity
+
+ -1
+ 120
+ 16
+
+
+
+ 61
+
+ ClipRight
+ User
+
+ -1
+ 90
+ 16
+
+
+
+ 62
+
+ ClipRight
+ Class
+
+ -1
+ 90
+ 16
+
+
+
+ 63
+
+ ClipRight
+ Method
+
+ -1
+ 120
+ 16
+
+
+
+ 64
+
+ ClipRight
+ File
+
+ -1
+ 120
+ 16
+
+
+
+ 65
+
+ ClipRight
+ Line
+
+ -1
+ 45
+ 16
+
+
+
+ 66
+
+ ClipRight
+ NDC
+
+ -1
+ 120
+ 16
+
+
+
+ 67
+
+ ClipRight
+ MDC
+
+ -1
+ 120
+ 16
+
+
+
+ 68
+
+ ClipRight
+ Comment
+
+ -1
+ 120
+ 16
+
+
+
+ 69
+
+ ClipRight
+ StackTrace
+
+ -1
+ 120
+ 16
+
+
+
+ 70
+
+ ClipRight
+ ProcessId
+
+ -1
+ 120
+ 16
+
+
+
+ 71
+
+ ClipRight
+ ThreadId
+
+ -1
+ 120
+ 16
+
+
+
+ 72
+
+ ClipRight
+ Date
+
+ -1
+ 70
+ 16
+
+
+
+ 73
+
+ ClipRight
+ CallStack
+
+ -1
+ 120
+ 16
+
+
+ <_filters z:Id="64" z:Size="0" />
+ <_formats z:Id="65" z:Size="1">
+
+
+ 0
+
+ Message
+
+
+
+
+
+ VERBOSE
+
+
+
+ 2
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4290032820
+
+
+ 8.25
+
+
+
+
+
+ TRACE
+
+
+
+ 3
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4288716960
+
+
+ 8.25
+
+
+
+
+
+ DEBUG
+
+
+
+ 4
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4286743170
+
+
+ 8.25
+
+
+
+
+
+ INFO
+
+
+
+ 5
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4278190080
+
+
+ 8.25
+
+
+
+
+
+ NOTICE
+
+
+
+ 6
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4281957177
+
+
+ 8.25
+
+
+
+
+
+ WARN
+
+
+
+ 7
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4294934528
+
+
+ 8.25
+
+
+
+
+
+ ERROR
+
+
+
+ 8
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4294901760
+
+
+ 8.25
+
+
+
+
+
+ SEVERE
+
+
+
+ 9
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4293067295
+
+
+ 8.25
+
+
+
+
+
+ CRITICAL
+
+
+
+ 10
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4289400377
+
+
+ 8.25
+
+
+
+
+
+ ALERT
+
+
+
+ 11
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4294902015
+
+
+ 8.25
+
+
+
+
+
+ FATAL
+
+
+
+ 12
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4287309977
+
+
+ 8.25
+
+
+
+
+
+ EMERGENCY
+
+
+
+ 13
+
+
+ 0
+
+ 0
+ 0
+
+ Tahoma
+
+ 0
+
+ 2
+ 4285932413
+
+
+ 8.25
+
+
+
+
+ false
+ Default Format Settings
+
+
+ <_logLevels z:Id="119" z:Size="0" />
+ <_loggers z:Id="120" z:Size="1">
+
+
+ 45
+
+
+
+ 14
+
+
+ <_receivers z:Id="122" z:Size="1">
+
+
+ 14
+
+
+ 0
+
+ 2
+ 4293654015
+
+ 500000
+ Windows-1252
+
+ Log4net
+ NzbDrone Reciver
+ XML
+ 0
+ 0001-01-01T00:00:00
+ 0001-01-01T00:00:00
+ 0
+ 0
+ Pacific Standard Time
+ false
+ 16
+ localhost
+ 20480
+
+
+ <_sources z:Id="129" z:Size="0" />
+
\ No newline at end of file
diff --git a/NzbDrone.6.0.ReSharper b/NzbDrone.6.0.ReSharper
deleted file mode 100644
index 7e7e31e71..000000000
--- a/NzbDrone.6.0.ReSharper
+++ /dev/null
@@ -1,149 +0,0 @@
-
-
-
-
- SOLUTION
-
-
-
-
-
-
- True
- False
- 2
- SEPARATE
- True
- True
- True
-
- - public
- - protected
- - internal
- - private
- - new
- - abstract
- - virtual
- - override
- - sealed
- - static
- - readonly
- - extern
- - unsafe
- - volatile
-
- False
- True
- True
- False
- False
- False
- True
- False
- False
- False
- False
- False
- True
- False
- False
- False
- False
- False
-
-
-
- - System.Linq
-
-
-
- $object$_On$event$
- $event$Handler
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $object$_On$event$
- $event$Handler
-
-
-
-
-
-
-
-
-
-
-
-
-
- $object$_On$event$
- $event$Handler
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - 43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD/d:Content/d:2011.3.1115
- - 43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD/d:Content/d:jQueryUI
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/NzbDrone.Common/IISProvider.cs b/NzbDrone.Common/IISProvider.cs
index e1bd23ea7..1d085286e 100644
--- a/NzbDrone.Common/IISProvider.cs
+++ b/NzbDrone.Common/IISProvider.cs
@@ -8,8 +8,8 @@ namespace NzbDrone.Common
{
public class IISProvider
{
- private static readonly Logger IISLogger = LogManager.GetLogger("Host.IISExpress");
- private static readonly Logger Logger = LogManager.GetLogger("Host.IISProvider");
+ private static readonly Logger IISLogger = LogManager.GetLogger("IISExpress");
+ private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigFileProvider _configFileProvider;
private readonly ProcessProvider _processProvider;
private readonly EnviromentProvider _enviromentProvider;
diff --git a/NzbDrone.Common/LogConfiguration.cs b/NzbDrone.Common/LogConfiguration.cs
index 84a1e9e51..a2633af4e 100644
--- a/NzbDrone.Common/LogConfiguration.cs
+++ b/NzbDrone.Common/LogConfiguration.cs
@@ -76,17 +76,40 @@ public static void RegisterUdpLogger()
}
- public static void RegisterFileLogger(string fileName)
+ private static FileTarget GetBaseTarget()
{
var fileTarget = new FileTarget();
fileTarget.AutoFlush = true;
- fileTarget.ConcurrentWrites = false;
- fileTarget.FileName = fileName;
+ fileTarget.ConcurrentWrites = true;
fileTarget.KeepFileOpen = false;
- fileTarget.Layout = "${longdate} - ${logger}: ${message} ${exception:format=ToString}";
+ fileTarget.ConcurrentWriteAttemptDelay = 50;
+ fileTarget.ConcurrentWriteAttempts = 200;
- LogManager.Configuration.AddTarget(fileTarget.GetType().Name, fileTarget);
- LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, fileTarget));
+ fileTarget.Layout = @"${date:format=yy-M-d HH\:mm\:ss.f}|${replace:searchFor=NzbDrone.:replaceWith=:inner=${logger}}|${message}|${exception:format=ToString}";
+
+ return fileTarget;
+ }
+
+ public static void RegisterFileLogger(string fileName, LogLevel level)
+ {
+ var fileTarget = GetBaseTarget();
+ fileTarget.FileName = fileName;
+
+ LogManager.Configuration.AddTarget(Guid.NewGuid().ToString(), fileTarget);
+ LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", level, fileTarget));
+ }
+
+ public static void RegisterRollingFileLogger(string fileName, LogLevel level)
+ {
+ var fileTarget = GetBaseTarget();
+ fileTarget.FileName = fileName;
+ fileTarget.ArchiveAboveSize = 200000; //500K
+ fileTarget.MaxArchiveFiles = 1;
+ fileTarget.EnableFileDelete = true;
+ fileTarget.ArchiveNumbering = ArchiveNumberingMode.Rolling;
+
+ LogManager.Configuration.AddTarget(Guid.NewGuid().ToString(), fileTarget);
+ LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", level, fileTarget));
}
public static void RegisterExceptioneer()
diff --git a/NzbDrone.Common/PathExtentions.cs b/NzbDrone.Common/PathExtentions.cs
index 8fd2e043b..58f997d34 100644
--- a/NzbDrone.Common/PathExtentions.cs
+++ b/NzbDrone.Common/PathExtentions.cs
@@ -139,5 +139,14 @@ public static string GetSandboxLogFolder(this EnviromentProvider enviromentProvi
{
return Path.Combine(enviromentProvider.GetUpdateSandboxFolder(), UPDATE_LOG_FOLDER_NAME);
}
+
+ public static string GetLogFileName(this EnviromentProvider enviromentProvider)
+ {
+ return Path.Combine(enviromentProvider.ApplicationPath, "nzbdrone.log.txt");
+ }
+ public static string GetArchivedLogFileName(this EnviromentProvider enviromentProvider)
+ {
+ return Path.Combine(enviromentProvider.ApplicationPath, "nzbdrone.log.0.txt");
+ }
}
}
\ No newline at end of file
diff --git a/NzbDrone.Common/ProcessProvider.cs b/NzbDrone.Common/ProcessProvider.cs
index a75f227b0..8be61ae00 100644
--- a/NzbDrone.Common/ProcessProvider.cs
+++ b/NzbDrone.Common/ProcessProvider.cs
@@ -8,7 +8,7 @@ namespace NzbDrone.Common
{
public class ProcessProvider
{
- private static readonly Logger Logger = LogManager.GetLogger("Host.ProcessProvider");
+ private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public static readonly string NzbDroneProccessName = "NzbDrone";
diff --git a/NzbDrone.Common/SecurityProvider.cs b/NzbDrone.Common/SecurityProvider.cs
index b0e567102..f70b5c0c6 100644
--- a/NzbDrone.Common/SecurityProvider.cs
+++ b/NzbDrone.Common/SecurityProvider.cs
@@ -1,19 +1,16 @@
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Principal;
-using System.Text;
using NLog;
using NetFwTypeLib;
using Ninject;
-using NzbDrone.Common.Model;
namespace NzbDrone.Common
{
public class SecurityProvider
{
- private static readonly Logger Logger = LogManager.GetLogger("Host.SecurityProvider");
+ private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigFileProvider _configFileProvider;
private readonly EnviromentProvider _enviromentProvider;
diff --git a/NzbDrone.Core.Test/ProviderTests/LogProviderTests/LogProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/LogProviderTests/LogProviderFixture.cs
index bd119158d..7e333b4de 100644
--- a/NzbDrone.Core.Test/ProviderTests/LogProviderTests/LogProviderFixture.cs
+++ b/NzbDrone.Core.Test/ProviderTests/LogProviderTests/LogProviderFixture.cs
@@ -32,10 +32,14 @@ public void Setup()
dbContext = Connection.GetLogDbContext(TestDbHelper.ConnectionString);
+ Mocker.SetConstant(dbContext);
+
new DatabaseTarget(Db).Register();
Logger = LogManager.GetCurrentClassLogger();
UniqueMessage = "Unique message: " + Guid.NewGuid().ToString();
+
+
}
[Test]
@@ -76,14 +80,15 @@ public void write_long_log()
[Test]
public void clearLog()
{
+ WithTempAsAppPath();
+
//Act
for (int i = 0; i < 10; i++)
{
Logger.Info(UniqueMessage);
}
-
- //Assert
- var provider = new LogProvider(Db, dbContext);
+
+ var provider = Mocker.Resolve();
provider.GetAllLogs().Should().HaveCount(10);
provider.DeleteAll();
provider.GetAllLogs().Should().HaveCount(1);
diff --git a/NzbDrone.Core/Instrumentation/LogProvider.cs b/NzbDrone.Core/Instrumentation/LogProvider.cs
index b01208e35..334c476dc 100644
--- a/NzbDrone.Core/Instrumentation/LogProvider.cs
+++ b/NzbDrone.Core/Instrumentation/LogProvider.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
+using NzbDrone.Common;
using PetaPoco;
namespace NzbDrone.Core.Instrumentation
@@ -10,14 +11,18 @@ public class LogProvider
{
private readonly IDatabase _database;
private readonly LogDbContext _logDbContext;
+ private readonly DiskProvider _diskProvider;
+ private readonly EnviromentProvider _enviromentProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
- public LogProvider(IDatabase database, LogDbContext logDbContext)
+ public LogProvider(IDatabase database, LogDbContext logDbContext, DiskProvider diskProvider, EnviromentProvider enviromentProvider)
{
_database = database;
_logDbContext = logDbContext;
+ _diskProvider = diskProvider;
+ _enviromentProvider = enviromentProvider;
}
public IQueryable GetAllLogs()
@@ -47,6 +52,8 @@ public Page GetPagedLogs(int pageNumber, int pageSize)
public void DeleteAll()
{
_database.Delete("");
+ _diskProvider.DeleteFile(_enviromentProvider.GetLogFileName());
+ _diskProvider.DeleteFile(_enviromentProvider.GetArchivedLogFileName());
Logger.Info("Cleared Log History");
}
diff --git a/NzbDrone.Update/Program.cs b/NzbDrone.Update/Program.cs
index 0e3ef7dfe..e9dd1a97a 100644
--- a/NzbDrone.Update/Program.cs
+++ b/NzbDrone.Update/Program.cs
@@ -68,7 +68,7 @@ private static void InitLoggers()
LogConfiguration.RegisterUdpLogger();
var logPath = Path.Combine(new EnviromentProvider().GetSandboxLogFolder(), DateTime.Now.ToString("yyyy.MM.dd-H-mm") + ".txt");
- LogConfiguration.RegisterFileLogger(logPath);
+ LogConfiguration.RegisterFileLogger(logPath, LogLevel.Info);
LogConfiguration.Reload();
}
diff --git a/NzbDrone.Web/App_Start/Logging.cs b/NzbDrone.Web/App_Start/Logging.cs
new file mode 100644
index 000000000..de6eba5ca
--- /dev/null
+++ b/NzbDrone.Web/App_Start/Logging.cs
@@ -0,0 +1,28 @@
+using System.IO;
+using System.Linq;
+using NLog;
+using NLog.Config;
+using NzbDrone.Common;
+
+[assembly: WebActivator.PreApplicationStartMethod(typeof(NzbDrone.Web.App_Start.Logging), "PreStart")]
+
+namespace NzbDrone.Web.App_Start
+{
+
+ public static class Logging
+ {
+ public static void PreStart()
+ {
+ var enviromentProvider = new EnviromentProvider();
+
+ LogManager.Configuration = new XmlLoggingConfiguration(enviromentProvider.GetNlogConfigPath(), false);
+
+ LogConfiguration.RegisterUdpLogger();
+ LogConfiguration.RegisterExceptioneer();
+ LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
+ LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
+ LogConfiguration.RegisterRollingFileLogger(enviromentProvider.GetLogFileName(), LogLevel.Trace);
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Web/Controllers/LogController.cs b/NzbDrone.Web/Controllers/LogController.cs
index d248a51c8..d25c76819 100644
--- a/NzbDrone.Web/Controllers/LogController.cs
+++ b/NzbDrone.Web/Controllers/LogController.cs
@@ -1,4 +1,7 @@
-using System.Web.Mvc;
+using System;
+using System.Text;
+using System.Web.Mvc;
+using NzbDrone.Common;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Web.Models;
using Telerik.Web.Mvc;
@@ -8,10 +11,14 @@ namespace NzbDrone.Web.Controllers
public class LogController : Controller
{
private readonly LogProvider _logProvider;
+ private readonly EnviromentProvider _enviromentProvider;
+ private readonly DiskProvider _diskProvider;
- public LogController(LogProvider logProvider)
+ public LogController(LogProvider logProvider, EnviromentProvider enviromentProvider, DiskProvider diskProvider)
{
_logProvider = logProvider;
+ _enviromentProvider = enviromentProvider;
+ _diskProvider = diskProvider;
}
public ActionResult Index()
@@ -19,6 +26,20 @@ public ActionResult Index()
return View();
}
+ public FileContentResult File()
+ {
+ string log = string.Empty;
+
+ if (_diskProvider.FileExists(_enviromentProvider.GetArchivedLogFileName()))
+ {
+ log = _diskProvider.ReadAllText(_enviromentProvider.GetArchivedLogFileName());
+ }
+
+ log += _diskProvider.ReadAllText(_enviromentProvider.GetLogFileName());
+
+ return new FileContentResult(Encoding.ASCII.GetBytes(log), "text/plain");
+ }
+
public JsonResult Clear()
{
_logProvider.DeleteAll();
diff --git a/NzbDrone.Web/Global.asax.cs b/NzbDrone.Web/Global.asax.cs
index b8c7a200e..de6417605 100644
--- a/NzbDrone.Web/Global.asax.cs
+++ b/NzbDrone.Web/Global.asax.cs
@@ -50,17 +50,8 @@ protected override void OnApplicationStarted()
protected override IKernel CreateKernel()
{
- LogManager.Configuration = new XmlLoggingConfiguration(new EnviromentProvider().GetNlogConfigPath(), false);
-
- LogConfiguration.RegisterUdpLogger();
- LogConfiguration.RegisterExceptioneer();
- LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
- LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
-
-
- var dispatch = new CentralDispatch();
Logger.Info("NzbDrone Starting up.");
-
+ var dispatch = new CentralDispatch();
dispatch.DedicateToHost();
dispatch.Kernel.Load(Assembly.GetExecutingAssembly());
diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj
index cdc12b345..cecff258d 100644
--- a/NzbDrone.Web/NzbDrone.Web.csproj
+++ b/NzbDrone.Web/NzbDrone.Web.csproj
@@ -198,6 +198,7 @@
UploadLocalization.en-US.resx
+
diff --git a/NzbDrone.Web/Views/Log/Index.cshtml b/NzbDrone.Web/Views/Log/Index.cshtml
index 71cbded41..1a19c49eb 100644
--- a/NzbDrone.Web/Views/Log/Index.cshtml
+++ b/NzbDrone.Web/Views/Log/Index.cshtml
@@ -1,4 +1,5 @@
@using NzbDrone.Core.Instrumentation
+@using NzbDrone.Web.Helpers
@model IEnumerable
@section Scripts{