From e3484bdcc204ae39e0bfdf08e758012a048d539c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 17 Dec 2014 17:39:17 -0500 Subject: 3.0.5464.40000 --- MediaBrowser.Common.Implementations/Logging/NLogger.cs | 13 ++++++++++++- MediaBrowser.Common.Implementations/Logging/NlogManager.cs | 8 +++++++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Common.Implementations/Logging') diff --git a/MediaBrowser.Common.Implementations/Logging/NLogger.cs b/MediaBrowser.Common.Implementations/Logging/NLogger.cs index c87b58f70..29b618890 100644 --- a/MediaBrowser.Common.Implementations/Logging/NLogger.cs +++ b/MediaBrowser.Common.Implementations/Logging/NLogger.cs @@ -14,6 +14,8 @@ namespace MediaBrowser.Common.Implementations.Logging /// private readonly NLog.Logger _logger; + private readonly ILogManager _logManager; + /// /// The _lock object /// @@ -23,8 +25,10 @@ namespace MediaBrowser.Common.Implementations.Logging /// Initializes a new instance of the class. /// /// The name. - public NLogger(string name) + /// The log manager. + public NLogger(string name, ILogManager logManager) { + _logManager = logManager; lock (LockObject) { _logger = NLog.LogManager.GetLogger(name); @@ -96,6 +100,13 @@ namespace MediaBrowser.Common.Implementations.Logging var messageText = LogHelper.GetLogMessage(exception); + var prefix = _logManager.ExceptionMessagePrefix; + + if (!string.IsNullOrWhiteSpace(prefix)) + { + messageText.Insert(0, prefix); + } + LogMultiline(message, level, messageText); } diff --git a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs index b18c6b95a..77d9f80f9 100644 --- a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs +++ b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs @@ -34,6 +34,12 @@ namespace MediaBrowser.Common.Implementations.Logging /// The log file path. public string LogFilePath { get; private set; } + /// + /// Gets or sets the exception message prefix. + /// + /// The exception message prefix. + public string ExceptionMessagePrefix { get; set; } + /// /// Initializes a new instance of the class. /// @@ -159,7 +165,7 @@ namespace MediaBrowser.Common.Implementations.Logging /// ILogger. public ILogger GetLogger(string name) { - return new NLogger(name); + return new NLogger(name, this); } /// -- cgit v1.2.3