From 253c943f8ed0b1e6836f27fb8b124eb51608716e Mon Sep 17 00:00:00 2001 From: Abhishek Vyas Date: Fri, 18 Nov 2016 12:02:54 -0600 Subject: [PATCH 1/2] #403 - Added code to support configuring application name for XML File Error Log. --- src/XmlFileErrorLog.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/XmlFileErrorLog.cs b/src/XmlFileErrorLog.cs index 18923dd..3313552 100644 --- a/src/XmlFileErrorLog.cs +++ b/src/XmlFileErrorLog.cs @@ -43,16 +43,36 @@ namespace Elmah public class XmlFileErrorLog : ErrorLog { private readonly string _logPath; + private const int MaxAppNameLength = 50; /// /// Initializes a new instance of the class /// using a dictionary of configured settings. /// - + public XmlFileErrorLog(IDictionary config) { string logPath = Mask.NullString(config["logPath"] as string); + // + // Set the application name as this implementation provides + // per-application isolation over shared location. + // + + string appName = string.Empty; + if (config.Contains("applicationName")) + { + appName = config["applicationName"].ToString(); + } + + if (appName.Length > MaxAppNameLength) + { + throw new ApplicationException(string.Format( + "Application name is too long. Maximum length allowed is {0} characters.", + MaxAppNameLength)); + } + ApplicationName = appName; + if (logPath.Length == 0) { // From 353884777a77e93debc629b59acb1e87345a41e3 Mon Sep 17 00:00:00 2001 From: Abhishek Vyas Date: Fri, 18 Nov 2016 15:09:23 -0600 Subject: [PATCH 2/2] #403 Made Max Application Name Length consistent with other loggers --- src/XmlFileErrorLog.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/XmlFileErrorLog.cs b/src/XmlFileErrorLog.cs index 3313552..8ed279f 100644 --- a/src/XmlFileErrorLog.cs +++ b/src/XmlFileErrorLog.cs @@ -43,7 +43,7 @@ namespace Elmah public class XmlFileErrorLog : ErrorLog { private readonly string _logPath; - private const int MaxAppNameLength = 50; + private const int MaxAppNameLength = 60; /// /// Initializes a new instance of the class