diff --git a/.gitignore b/.gitignore
index f870b39..51a1335 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
*.user
obj/
bin/
+.vs/
\ No newline at end of file
diff --git a/README.md b/README.md
index 514aa6e..b4006bc 100644
--- a/README.md
+++ b/README.md
@@ -46,9 +46,23 @@ Isolate per application in a single Elmah store
+By application setting:
+
+
+
+Make sure you add an element under the `appSettings` element.
+
### Table Name
Set a custom table name (defaults to "Elmah"):
+
+By application setting:
+
+
+
+Make sure you add an element under the `appSettings` element.
diff --git a/src/Elmah.AzureTableStorage/AzureTableStorageErrorLog.cs b/src/Elmah.AzureTableStorage/AzureTableStorageErrorLog.cs
index 356e2e1..5ec7a05 100644
--- a/src/Elmah.AzureTableStorage/AzureTableStorageErrorLog.cs
+++ b/src/Elmah.AzureTableStorage/AzureTableStorageErrorLog.cs
@@ -44,9 +44,11 @@ public AzureTableStorageErrorLog(IDictionary config)
// Get custom table name for storage and validate
//
- var tableName = config.Find("tableName", DefaultTableName);
+ var tableName = ElmahHelper.GetTableName(config);
+ if (tableName.Length == 0)
+ tableName = DefaultTableName;
- if(!Regex.IsMatch(tableName, TableValidationRegex))
+ if (!Regex.IsMatch(tableName, TableValidationRegex))
throw new ApplicationException("Name for table in Azure Table Storage is not a valid name.");
var cloudStorageAccount = CloudStorageAccount.Parse(connectionString);
@@ -59,7 +61,7 @@ public AzureTableStorageErrorLog(IDictionary config)
// per-application isolation over a single store.
//
- var appName = config.Find("applicationName", string.Empty);
+ var appName = ElmahHelper.GetApplicationName(config);
if (appName.Length > MaxAppNameLength)
{
diff --git a/src/Elmah.AzureTableStorage/ElmahHelper.cs b/src/Elmah.AzureTableStorage/ElmahHelper.cs
index 8364c81..71bdd78 100644
--- a/src/Elmah.AzureTableStorage/ElmahHelper.cs
+++ b/src/Elmah.AzureTableStorage/ElmahHelper.cs
@@ -57,5 +57,45 @@ public static string GetConnectionString(IDictionary config)
? CloudConfigurationManager.GetSetting(connectionStringAppKey)
: string.Empty;
}
+
+ public static string GetApplicationName(IDictionary config)
+ {
+ // Check for application name
+ var applicationName = config.Find("applicationName", string.Empty);
+ if (applicationName.Length > 0)
+ return applicationName;
+
+ // If not found then check for Key
+ var applicationNameAppKey = config.Find("applicationNameAppKey", string.Empty);
+ if (applicationNameAppKey.Length > 0)
+ {
+ applicationName = CloudConfigurationManager.GetSetting(applicationNameAppKey);
+
+ if (applicationName == null)
+ return string.Empty;
+ }
+
+ return applicationName;
+ }
+
+ public static string GetTableName(IDictionary config)
+ {
+ // Check for table name
+ var tableName = config.Find("tableName", string.Empty);
+ if (tableName.Length > 0)
+ return tableName;
+
+ // If not found then check for Key
+ var tableNameAppKey = config.Find("tableNameAppKey", string.Empty);
+ if (tableNameAppKey.Length > 0)
+ {
+ tableName = CloudConfigurationManager.GetSetting(tableNameAppKey);
+
+ if (tableName == null)
+ return string.Empty;
+ }
+
+ return tableName;
+ }
}
}