aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/Logging
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common.Implementations/Logging')
-rw-r--r--MediaBrowser.Common.Implementations/Logging/NLogger.cs13
-rw-r--r--MediaBrowser.Common.Implementations/Logging/NlogManager.cs8
2 files changed, 19 insertions, 2 deletions
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
/// </summary>
private readonly NLog.Logger _logger;
+ private readonly ILogManager _logManager;
+
/// <summary>
/// The _lock object
/// </summary>
@@ -23,8 +25,10 @@ namespace MediaBrowser.Common.Implementations.Logging
/// Initializes a new instance of the <see cref="NLogger" /> class.
/// </summary>
/// <param name="name">The name.</param>
- public NLogger(string name)
+ /// <param name="logManager">The log manager.</param>
+ 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
@@ -35,6 +35,12 @@ namespace MediaBrowser.Common.Implementations.Logging
public string LogFilePath { get; private set; }
/// <summary>
+ /// Gets or sets the exception message prefix.
+ /// </summary>
+ /// <value>The exception message prefix.</value>
+ public string ExceptionMessagePrefix { get; set; }
+
+ /// <summary>
/// Initializes a new instance of the <see cref="NlogManager" /> class.
/// </summary>
/// <param name="logDirectory">The log directory.</param>
@@ -159,7 +165,7 @@ namespace MediaBrowser.Common.Implementations.Logging
/// <returns>ILogger.</returns>
public ILogger GetLogger(string name)
{
- return new NLogger(name);
+ return new NLogger(name, this);
}
/// <summary>