From 9e996c68bbd9e6aba0138c2a1995f9b8df159923 Mon Sep 17 00:00:00 2001 From: Warren Date: Fri, 17 Aug 2018 15:41:58 +0100 Subject: [PATCH] Refactored the error params, so that exception is before the message/template so its more in sync with Serilog signature & was an easy way to find some more logs I missed too --- src/Umbraco.Core/Components/BootLoader.cs | 2 +- src/Umbraco.Core/Composing/TypeFinder.cs | 6 +++--- src/Umbraco.Core/Composing/TypeLoader.cs | 2 +- .../ClientDependencyConfiguration.cs | 8 ++++---- .../Configuration/Grid/GridEditorsConfig.cs | 2 +- src/Umbraco.Core/Configuration/UmbracoConfig.cs | 6 +++--- src/Umbraco.Core/IO/MediaFileSystem.cs | 2 +- src/Umbraco.Core/IO/PhysicalFileSystem.cs | 12 ++++++------ .../Logging/DebugDiagnosticsLogger.cs | 4 ++-- src/Umbraco.Core/Logging/DisposableTimer.cs | 2 +- src/Umbraco.Core/Logging/ILogger.cs | 8 ++++---- src/Umbraco.Core/Logging/ImageProcessorLogger.cs | 4 ++-- src/Umbraco.Core/Logging/Logger.cs | 8 ++++---- src/Umbraco.Core/Logging/LoggerExtensions.cs | 8 ++++---- src/Umbraco.Core/Logging/OwinLogger.cs | 4 ++-- src/Umbraco.Core/MainDom.cs | 2 +- src/Umbraco.Core/Manifest/ManifestParser.cs | 2 +- .../Media/UploadAutoFillProperties.cs | 2 +- .../Migrations/Install/DatabaseBuilder.cs | 2 +- .../Migrations/Install/DatabaseSchemaCreator.cs | 2 +- src/Umbraco.Core/Models/MediaExtensions.cs | 2 +- .../Packaging/PackageBinaryInspector.cs | 4 ++-- .../Implement/ContentTypeRepository.cs | 2 +- .../Implement/ContentTypeRepositoryBase.cs | 7 +++---- .../Persistence/SqlSyntax/MySqlSyntaxProvider.cs | 2 +- src/Umbraco.Core/Persistence/UmbracoDatabase.cs | 2 +- .../ValueConverters/GridValueConverter.cs | 2 +- .../ImageCropperValueConverter.cs | 2 +- .../ValueConverters/JsonValueConverter.cs | 2 +- .../Publishing/ScheduledPublisher.cs | 10 +++++----- .../Security/MembershipProviderBase.cs | 2 +- .../Services/Implement/ContentService.cs | 10 +++++----- .../Implement/LocalizedTextServiceFileSources.cs | 2 +- .../Services/Implement/MediaService.cs | 2 +- .../Services/Implement/MemberService.cs | 2 +- .../Services/Implement/NotificationService.cs | 2 +- .../Services/Implement/PackagingService.cs | 8 ++++---- src/Umbraco.Core/Sync/DatabaseServerMessenger.cs | 5 ++--- src/Umbraco.Core/UmbracoApplicationBase.cs | 6 +++--- src/Umbraco.Core/UriExtensions.cs | 2 +- src/Umbraco.Examine/UmbracoExamineIndexer.cs | 8 ++++---- src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs | 6 +++--- .../TestHelpers/TestWithDatabaseBase.cs | 2 +- ...tabaseServerRegistrarAndMessengerComponent.cs | 2 +- src/Umbraco.Web/Editors/ContentController.cs | 2 +- src/Umbraco.Web/Editors/ContentTypeController.cs | 2 +- src/Umbraco.Web/Editors/DashboardController.cs | 4 ++-- src/Umbraco.Web/Editors/DictionaryController.cs | 8 ++++---- .../Editors/ExamineManagementController.cs | 2 +- src/Umbraco.Web/Editors/MediaController.cs | 2 +- .../Editors/PackageInstallController.cs | 8 ++++---- .../Checks/Config/ConfigurationService.cs | 12 ++++++------ .../HealthCheck/HealthCheckController.cs | 4 ++-- .../HealthCheck/HealthCheckResults.cs | 2 +- .../ImageCropperTemplateExtensions.cs | 2 +- .../Install/Controllers/InstallApiController.cs | 8 ++++---- .../Install/HttpInstallAuthorizeAttribute.cs | 2 +- src/Umbraco.Web/Install/InstallHelper.cs | 4 ++-- .../InstallSteps/DatabaseConfigureStep.cs | 2 +- .../Install/InstallSteps/DatabaseInstallStep.cs | 2 +- .../Mapping/ContentPropertyBasicConverter.cs | 5 +++-- .../Mvc/AdminTokenAuthorizeAttribute.cs | 2 +- .../ImageCropperPropertyEditor.cs | 2 +- .../PropertyEditors/RteEmbedController.cs | 2 +- .../RelatedLinksLegacyValueConverter.cs | 4 ++-- .../RelatedLinksValueConverter.cs | 2 +- .../NuCache/PublishedSnapshotService.cs | 4 ++-- .../XmlPublishedCache/PreviewContent.cs | 4 ++-- .../XmlPublishedCache/PublishedMediaCache.cs | 8 ++++---- .../PublishedCache/XmlPublishedCache/XmlStore.cs | 16 ++++++++-------- src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs | 2 +- src/Umbraco.Web/Routing/UrlProviderExtensions.cs | 4 ++-- .../Scheduling/BackgroundTaskRunner.cs | 8 ++++---- src/Umbraco.Web/Scheduling/KeepAlive.cs | 4 ++-- src/Umbraco.Web/Scheduling/LogScrubber.cs | 8 ++++---- .../Scheduling/ScheduledPublishing.cs | 4 ++-- src/Umbraco.Web/Scheduling/ScheduledTasks.cs | 6 +++--- src/Umbraco.Web/Search/ExamineComponent.cs | 8 ++++---- .../Identity/AuthenticationOptionsExtensions.cs | 2 +- src/Umbraco.Web/Trees/LegacyTreeController.cs | 15 ++++++--------- src/Umbraco.Web/Trees/LegacyTreeJavascript.cs | 6 +++--- src/Umbraco.Web/UI/CdfLogger.cs | 4 ++-- src/Umbraco.Web/UI/Pages/UmbracoEnsuredPage.cs | 2 +- src/Umbraco.Web/UmbracoModule.cs | 6 +++--- .../WebApi/Filters/AngularAntiForgeryHelper.cs | 2 +- .../Filters/FileUploadCleanupFilterAttribute.cs | 14 +++++++------- .../WebApi/UnhandledExceptionLogger.cs | 2 +- src/Umbraco.Web/_Legacy/Actions/Action.cs | 4 ++-- .../PackageActions/addStringToHtmlElement.cs | 4 ++-- src/Umbraco.Web/_Legacy/Packager/Installer.cs | 12 ++++++------ .../Packager/PackageInstance/InstalledPackage.cs | 2 +- .../Packager/PackageInstance/PackageActions.cs | 8 ++++---- src/Umbraco.Web/_Legacy/Packager/data.cs | 2 +- .../umbraco/controls/Tree/JTreeContextMenu.cs | 4 ++-- .../umbraco/dashboard/FeedProxy.aspx.cs | 4 ++-- .../umbraco/dialogs/protectPage.aspx.cs | 2 +- .../umbraco/dialogs/sendToTranslation.aspx.cs | 2 +- .../umbraco/webservices/nodeSorter.asmx.cs | 4 ++-- 98 files changed, 219 insertions(+), 223 deletions(-) diff --git a/src/Umbraco.Core/Components/BootLoader.cs b/src/Umbraco.Core/Components/BootLoader.cs index d045d45bf2..fd292990c8 100644 --- a/src/Umbraco.Core/Components/BootLoader.cs +++ b/src/Umbraco.Core/Components/BootLoader.cs @@ -112,7 +112,7 @@ namespace Umbraco.Core.Components { // in case of an error, force-dump everything to log _logger.Info("Component Report:\r\n{ComponentReport}", GetComponentsReport(requirements)); - _logger.Error("Failed to sort compontents.", e); + _logger.Error(e, "Failed to sort compontents."); throw; } diff --git a/src/Umbraco.Core/Composing/TypeFinder.cs b/src/Umbraco.Core/Composing/TypeFinder.cs index 23ba41e99d..a42b84e0c5 100644 --- a/src/Umbraco.Core/Composing/TypeFinder.cs +++ b/src/Umbraco.Core/Composing/TypeFinder.cs @@ -148,7 +148,7 @@ namespace Umbraco.Core.Composing catch (FileNotFoundException ex) { //this will occur if it cannot load the assembly - Current.Logger.Error(typeof(TypeFinder), "Could not load assembly App_Code", ex); + Current.Logger.Error(typeof(TypeFinder), ex, "Could not load assembly App_Code"); } } } @@ -439,7 +439,7 @@ namespace Umbraco.Core.Composing } catch (TypeLoadException ex) { - Current.Logger.Error(typeof(TypeFinder), "Could not query types on {Assembly} assembly, this is most likely due to this assembly not being compatible with the current Umbraco version", ex, assembly); + Current.Logger.Error(typeof(TypeFinder), ex, "Could not query types on {Assembly} assembly, this is most likely due to this assembly not being compatible with the current Umbraco version", assembly); continue; } @@ -505,7 +505,7 @@ namespace Umbraco.Core.Composing } catch (TypeLoadException ex) { - Current.Logger.Error(typeof(TypeFinder), "Could not query types on {Assembly} assembly, this is most likely due to this assembly not being compatible with the current Umbraco version", ex, assembly); + Current.Logger.Error(typeof(TypeFinder), ex, "Could not query types on {Assembly} assembly, this is most likely due to this assembly not being compatible with the current Umbraco version", assembly); continue; } diff --git a/src/Umbraco.Core/Composing/TypeLoader.cs b/src/Umbraco.Core/Composing/TypeLoader.cs index c35ecb2feb..304638e017 100644 --- a/src/Umbraco.Core/Composing/TypeLoader.cs +++ b/src/Umbraco.Core/Composing/TypeLoader.cs @@ -695,7 +695,7 @@ namespace Umbraco.Core.Composing catch (Exception ex) { // in case of any exception, we have to exit, and revert to scanning - _logger.Logger.Error("Getting {TypeName}: failed to load cache file type {CacheType}, reverting to scanning assemblies.", ex, GetName(baseType, attributeType), type); + _logger.Logger.Error(ex, "Getting {TypeName}: failed to load cache file type {CacheType}, reverting to scanning assemblies.", GetName(baseType, attributeType), type); scan = true; break; } diff --git a/src/Umbraco.Core/Configuration/ClientDependencyConfiguration.cs b/src/Umbraco.Core/Configuration/ClientDependencyConfiguration.cs index fa3cafce04..61f9023167 100644 --- a/src/Umbraco.Core/Configuration/ClientDependencyConfiguration.cs +++ b/src/Umbraco.Core/Configuration/ClientDependencyConfiguration.cs @@ -85,7 +85,7 @@ namespace Umbraco.Core.Configuration } catch (Exception ex) { - _logger.Error("Couldn't update ClientDependency version number", ex); + _logger.Error(ex, "Couldn't update ClientDependency version number"); } return false; @@ -119,7 +119,7 @@ namespace Umbraco.Core.Configuration } catch (Exception ex) { - _logger.Error("Couldn't update ClientDependency version number", ex); + _logger.Error(ex, "Couldn't update ClientDependency version number"); } return false; @@ -150,7 +150,7 @@ namespace Umbraco.Core.Configuration catch (Exception ex) { //invalid path format or something... try/catch to be safe - _logger.Error("Could not get path from ClientDependency.config", ex); + _logger.Error(ex, "Could not get path from ClientDependency.config"); } var success = true; @@ -167,7 +167,7 @@ namespace Umbraco.Core.Configuration catch (Exception ex) { // Something could be locking the directory or the was another error, making sure we don't break the upgrade installer - _logger.Error("Could not clear temp files", ex); + _logger.Error(ex, "Could not clear temp files"); success = false; } } diff --git a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs index e7e20e157b..708c563d9d 100644 --- a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs +++ b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs @@ -48,7 +48,7 @@ namespace Umbraco.Core.Configuration.Grid } catch (Exception ex) { - _logger.Error("Could not parse the contents of grid.editors.config.js into a JSON array '{Json}", ex, sourceString); + _logger.Error(ex, "Could not parse the contents of grid.editors.config.js into a JSON array '{Json}", sourceString); } } diff --git a/src/Umbraco.Core/Configuration/UmbracoConfig.cs b/src/Umbraco.Core/Configuration/UmbracoConfig.cs index 248736d0fe..6dd5617992 100644 --- a/src/Umbraco.Core/Configuration/UmbracoConfig.cs +++ b/src/Umbraco.Core/Configuration/UmbracoConfig.cs @@ -88,7 +88,7 @@ namespace Umbraco.Core.Configuration if (_healthChecks == null) { var ex = new ConfigurationErrorsException("Could not load the " + typeof(IHealthChecks) + " from config file, ensure the web.config and healthchecks.config files are formatted correctly"); - Current.Logger.Error("Config error", ex); + Current.Logger.Error(ex, "Config error"); throw ex; } @@ -103,7 +103,7 @@ namespace Umbraco.Core.Configuration if (_dashboardSection == null) { var ex = new ConfigurationErrorsException("Could not load the " + typeof(IDashboardSection) + " from config file, ensure the web.config and Dashboard.config files are formatted correctly"); - Current.Logger.Error("Config error", ex); + Current.Logger.Error(ex, "Config error"); throw ex; } @@ -162,7 +162,7 @@ namespace Umbraco.Core.Configuration if (_umbracoSettings == null) { var ex = new ConfigurationErrorsException("Could not load the " + typeof (IUmbracoSettingsSection) + " from config file, ensure the web.config and umbracoSettings.config files are formatted correctly"); - Current.Logger.Error("Config error", ex); + Current.Logger.Error(ex, "Config error"); throw ex; } diff --git a/src/Umbraco.Core/IO/MediaFileSystem.cs b/src/Umbraco.Core/IO/MediaFileSystem.cs index b9ee8337f6..dedad995eb 100644 --- a/src/Umbraco.Core/IO/MediaFileSystem.cs +++ b/src/Umbraco.Core/IO/MediaFileSystem.cs @@ -111,7 +111,7 @@ namespace Umbraco.Core.IO } catch (Exception e) { - Logger.Error("Failed to delete attached file '{File}'", e, file); + Logger.Error(e, "Failed to delete attached file '{File}'", file); } }); } diff --git a/src/Umbraco.Core/IO/PhysicalFileSystem.cs b/src/Umbraco.Core/IO/PhysicalFileSystem.cs index 51f3117a40..217ecb51b4 100644 --- a/src/Umbraco.Core/IO/PhysicalFileSystem.cs +++ b/src/Umbraco.Core/IO/PhysicalFileSystem.cs @@ -73,11 +73,11 @@ namespace Umbraco.Core.IO } catch (UnauthorizedAccessException ex) { - Current.Logger.Error("Not authorized to get directories for '{Path}'", ex, fullPath); + Current.Logger.Error(ex, "Not authorized to get directories for '{Path}'", fullPath); } catch (DirectoryNotFoundException ex) { - Current.Logger.Error("Directory not found for '{Path}'", ex, fullPath); + Current.Logger.Error(ex, "Directory not found for '{Path}'", fullPath); } return Enumerable.Empty(); @@ -109,7 +109,7 @@ namespace Umbraco.Core.IO } catch (DirectoryNotFoundException ex) { - Current.Logger.Error("Directory not found for '{Path}'", ex, fullPath); + Current.Logger.Error(ex, "Directory not found for '{Path}'", fullPath); } } @@ -189,11 +189,11 @@ namespace Umbraco.Core.IO } catch (UnauthorizedAccessException ex) { - Current.Logger.Error("Not authorized to get directories for '{Path}'", ex, fullPath); + Current.Logger.Error(ex, "Not authorized to get directories for '{Path}'", fullPath); } catch (DirectoryNotFoundException ex) { - Current.Logger.Error("Directory not found for '{FullPath}'", ex, fullPath); + Current.Logger.Error(ex, "Directory not found for '{FullPath}'", fullPath); } return Enumerable.Empty(); @@ -226,7 +226,7 @@ namespace Umbraco.Core.IO } catch (FileNotFoundException ex) { - Current.Logger.Error("DeleteFile failed with FileNotFoundException for '{Path}'", ex.InnerException, fullPath); + Current.Logger.Error(ex.InnerException, "DeleteFile failed with FileNotFoundException for '{Path}'", fullPath); } } diff --git a/src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs b/src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs index 8d1b510de0..a2c7a3c714 100644 --- a/src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs +++ b/src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs @@ -8,13 +8,13 @@ namespace Umbraco.Core.Logging public class DebugDiagnosticsLogger : ILogger { /// - public void Error(Type reporting, string message, Exception exception = null) + public void Error(Type reporting, Exception exception, string message) { System.Diagnostics.Debug.WriteLine(message + Environment.NewLine + exception, reporting.FullName); } /// - public void Error(Type reporting, string messageTemplate, Exception exception = null, params object[] args) + public void Error(Type reporting, Exception exception, string messageTemplate, params object[] args) { System.Diagnostics.Debug.WriteLine(string.Format(messageTemplate, args) + Environment.NewLine + exception, reporting.FullName); } diff --git a/src/Umbraco.Core/Logging/DisposableTimer.cs b/src/Umbraco.Core/Logging/DisposableTimer.cs index a5c914153b..e1e9d29c5f 100644 --- a/src/Umbraco.Core/Logging/DisposableTimer.cs +++ b/src/Umbraco.Core/Logging/DisposableTimer.cs @@ -92,7 +92,7 @@ namespace Umbraco.Core.Logging { if (_failed) { - _logger.Error(_loggerType, "[Timing {TimingId}] {FailMessage} ({TimingDuration}ms)", _failException, _timingId, _failMessage, Stopwatch.ElapsedMilliseconds); + _logger.Error(_loggerType, _failException, "[Timing {TimingId}] {FailMessage} ({TimingDuration}ms)", _timingId, _failMessage, Stopwatch.ElapsedMilliseconds); } else switch (_logType) { diff --git a/src/Umbraco.Core/Logging/ILogger.cs b/src/Umbraco.Core/Logging/ILogger.cs index 7ee17dfe62..0f9e79230a 100644 --- a/src/Umbraco.Core/Logging/ILogger.cs +++ b/src/Umbraco.Core/Logging/ILogger.cs @@ -11,18 +11,18 @@ namespace Umbraco.Core.Logging /// Logs an error message. /// /// The reporting type. - /// A message. /// An exception. - void Error(Type reporting, string message, Exception exception = null); + /// A message. + void Error(Type reporting, Exception exception, string message); /// /// Logs an error message - using a structured log message /// /// The reporting type. - /// The message template that includes property values /// An exception. + /// The message template that includes property values /// Property values to log & update in message template - void Error(Type reporting, string messageTemplate, Exception exception = null, params object[] propertyValues); + void Error(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues); /// /// Logs a warning message. diff --git a/src/Umbraco.Core/Logging/ImageProcessorLogger.cs b/src/Umbraco.Core/Logging/ImageProcessorLogger.cs index 02faac39aa..759ba0ccc4 100644 --- a/src/Umbraco.Core/Logging/ImageProcessorLogger.cs +++ b/src/Umbraco.Core/Logging/ImageProcessorLogger.cs @@ -27,7 +27,7 @@ namespace Umbraco.Core.Logging { // Using LogHelper since the ImageProcessor logger expects a parameterless constructor. var message = $"{callerName} {lineNumber} : {text}"; - Current.Logger.Error(string.Empty, new ImageProcessingException(message)); + Current.Logger.Error(new ImageProcessingException(message), string.Empty); } /// @@ -41,7 +41,7 @@ namespace Umbraco.Core.Logging { // Using LogHelper since the ImageProcessor logger expects a parameterless constructor. var message = $"{callerName} {lineNumber} : {text}"; - Current.Logger.Error(type, string.Empty, new ImageProcessingException(message)); + Current.Logger.Error(type, new ImageProcessingException(message), string.Empty); } } } diff --git a/src/Umbraco.Core/Logging/Logger.cs b/src/Umbraco.Core/Logging/Logger.cs index fb9bf4c9f0..95027ec3de 100644 --- a/src/Umbraco.Core/Logging/Logger.cs +++ b/src/Umbraco.Core/Logging/Logger.cs @@ -51,7 +51,7 @@ namespace Umbraco.Core.Logging /// [Obsolete("Use the message template version")] - public void Error(Type reporting, string message, Exception exception = null) + public void Error(Type reporting, Exception exception, string message) { var logger = Log.Logger; if (logger == null) return; @@ -87,7 +87,7 @@ namespace Umbraco.Core.Logging logger.ForContext(reporting).Error(exception, message); } - public void Error(Type reporting, string messageTemplate, Exception exception = null, params object[] propertyValues) + public void Error(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues) { var dump = false; @@ -111,10 +111,10 @@ namespace Umbraco.Core.Logging ? "\r\nA minidump was created in App_Data/MiniDump" : "\r\nFailed to create a minidump"; } - catch (Exception e) + catch (Exception ex) { //Log a new entry (as opposed to appending to same log entry) - Error(e.GetType(), "Failed to create a minidump at App_Data/MiniDump ({ExType}: {ExMessage}", e, e.GetType().FullName, e.Message); + Error(ex.GetType(), ex, "Failed to create a minidump at App_Data/MiniDump ({ExType}: {ExMessage}", ex.GetType().FullName, ex.Message); } } diff --git a/src/Umbraco.Core/Logging/LoggerExtensions.cs b/src/Umbraco.Core/Logging/LoggerExtensions.cs index a970a9ab00..211776b564 100644 --- a/src/Umbraco.Core/Logging/LoggerExtensions.cs +++ b/src/Umbraco.Core/Logging/LoggerExtensions.cs @@ -14,9 +14,9 @@ namespace Umbraco.Core.Logging /// The logger. /// A message. /// An exception. - public static void Error(this ILogger logger, string message, Exception exception = null) + public static void Error(this ILogger logger, Exception exception, string message) { - logger.Error(typeof(T), message, exception); + logger.Error(typeof(T), exception, message); } /// @@ -27,9 +27,9 @@ namespace Umbraco.Core.Logging /// A structured message template /// An exception /// Message property values - public static void Error(this ILogger logger, string messageTemplate, Exception exception = null, params object[] propertyValues) + public static void Error(this ILogger logger, Exception exception, string messageTemplate, params object[] propertyValues) { - logger.Error(typeof(T), messageTemplate, exception, propertyValues); + logger.Error(typeof(T), exception, messageTemplate, propertyValues); } /// diff --git a/src/Umbraco.Core/Logging/OwinLogger.cs b/src/Umbraco.Core/Logging/OwinLogger.cs index 692065d150..fd4699b542 100644 --- a/src/Umbraco.Core/Logging/OwinLogger.cs +++ b/src/Umbraco.Core/Logging/OwinLogger.cs @@ -26,10 +26,10 @@ namespace Umbraco.Core.Logging switch (eventType) { case TraceEventType.Critical: - _logger.Error(_type.Value, "[{EventType}] Event Id: {EventId}, State: {State}", exception ?? new Exception("Critical error"), eventType, eventId, state); + _logger.Fatal(_type.Value, exception ?? new Exception("Critical error"), "[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); return true; case TraceEventType.Error: - _logger.Error(_type.Value, "[{EventType}] Event Id: {EventId}, State: {State}", exception ?? new Exception("Error"), eventType, eventId, state); + _logger.Error(_type.Value, exception ?? new Exception("Error"), "[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); return true; case TraceEventType.Warning: _logger.Warn(_type.Value, "[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); diff --git a/src/Umbraco.Core/MainDom.cs b/src/Umbraco.Core/MainDom.cs index 5cdabc44f5..eb036fd441 100644 --- a/src/Umbraco.Core/MainDom.cs +++ b/src/Umbraco.Core/MainDom.cs @@ -134,7 +134,7 @@ namespace Umbraco.Core } catch (Exception e) { - _logger.Error("Error while running callback, remaining callbacks will not run.", e); + _logger.Error(e, "Error while running callback, remaining callbacks will not run."); throw; } diff --git a/src/Umbraco.Core/Manifest/ManifestParser.cs b/src/Umbraco.Core/Manifest/ManifestParser.cs index fe5fe80363..e2363e314f 100644 --- a/src/Umbraco.Core/Manifest/ManifestParser.cs +++ b/src/Umbraco.Core/Manifest/ManifestParser.cs @@ -81,7 +81,7 @@ namespace Umbraco.Core.Manifest } catch (Exception e) { - _logger.Error($"Failed to parse manifest at '{Path}', ignoring.", e, path); + _logger.Error(e, "Failed to parse manifest at '{Path}', ignoring.", path); } } diff --git a/src/Umbraco.Core/Media/UploadAutoFillProperties.cs b/src/Umbraco.Core/Media/UploadAutoFillProperties.cs index 488bc194b6..2045e947ac 100644 --- a/src/Umbraco.Core/Media/UploadAutoFillProperties.cs +++ b/src/Umbraco.Core/Media/UploadAutoFillProperties.cs @@ -153,7 +153,7 @@ namespace Umbraco.Core.Media } catch (Exception ex) { - _logger.Error(typeof(UploadAutoFillProperties), "Could not populate upload auto-fill properties for file '{File}'.", ex, filepath); + _logger.Error(typeof(UploadAutoFillProperties), ex, "Could not populate upload auto-fill properties for file '{File}'.", filepath); ResetProperties(content, autoFillConfig, culture, segment); } } diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs index 7e81c132a0..4986eeab02 100644 --- a/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs +++ b/src/Umbraco.Core/Migrations/Install/DatabaseBuilder.cs @@ -658,7 +658,7 @@ namespace Umbraco.Core.Migrations.Install private Result HandleInstallException(Exception ex) { - _logger.Error("Database configuration failed", ex); + _logger.Error(ex, "Database configuration failed"); if (_databaseSchemaValidationResult != null) { diff --git a/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs b/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs index bb8833e5cf..931f82ab77 100644 --- a/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs +++ b/src/Umbraco.Core/Migrations/Install/DatabaseSchemaCreator.cs @@ -109,7 +109,7 @@ namespace Umbraco.Core.Migrations.Install { //swallow this for now, not sure how best to handle this with diff databases... though this is internal // and only used for unit tests. If this fails its because the table doesn't exist... generally! - _logger.Error("Could not drop table {TableName}", ex, tableName); + _logger.Error(ex, "Could not drop table {TableName}", tableName); } } } diff --git a/src/Umbraco.Core/Models/MediaExtensions.cs b/src/Umbraco.Core/Models/MediaExtensions.cs index 5d0c911663..f510377c09 100644 --- a/src/Umbraco.Core/Models/MediaExtensions.cs +++ b/src/Umbraco.Core/Models/MediaExtensions.cs @@ -41,7 +41,7 @@ namespace Umbraco.Core.Models } catch (Exception ex) { - logger.Error("Could not parse the string '{JsonString}' to a json object", ex, jsonString); + logger.Error(ex, "Could not parse the string '{JsonString}' to a json object", jsonString); return string.Empty; } } diff --git a/src/Umbraco.Core/Packaging/PackageBinaryInspector.cs b/src/Umbraco.Core/Packaging/PackageBinaryInspector.cs index adf90147f8..7cacb30bd3 100644 --- a/src/Umbraco.Core/Packaging/PackageBinaryInspector.cs +++ b/src/Umbraco.Core/Packaging/PackageBinaryInspector.cs @@ -192,7 +192,7 @@ namespace Umbraco.Core.Packaging assemblyName.Name, "' see error log for full details.")); assembliesWithErrors.Add(a); - Current.Logger.Error("An error occurred scanning package assembly '{AssemblyName}'", ex, assemblyName.FullName); + Current.Logger.Error(ex, "An error occurred scanning package assembly '{AssemblyName}'", assemblyName.FullName); } } } @@ -236,7 +236,7 @@ namespace Umbraco.Core.Packaging a.GetName().Name, "' see error log for full details.")); assembliesWithErrors.Add(a); - Current.Logger.Error("An error occurred scanning package assembly '{AssemblyName}'", ex, a.GetName().FullName); + Current.Logger.Error(ex, "An error occurred scanning package assembly '{AssemblyName}'", a.GetName().FullName); } } diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs index 8d28b74c46..8fc9cdebcb 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepository.cs @@ -228,7 +228,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement if (string.IsNullOrWhiteSpace(entity.Alias)) { var e = new Exception($"ContentType '{entity.Name}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias."); - Logger.Error("ContentType '{EntityName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.", e, entity.Name); + Logger.Error(e, "ContentType '{EntityName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.", entity.Name); throw e; } diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs index 91e9b12704..0dfc25a5ff 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs @@ -523,9 +523,9 @@ AND umbracoNode.id <> @id", { var e = new InvalidOperationException($"Property Type '{pt.Name}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias."); - Logger.Error>( + Logger.Error>(e, "Property Type '{PropertyTypeName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.", - e, pt.Name); + pt.Name); throw e; } @@ -537,8 +537,7 @@ AND umbracoNode.id <> @id", { var ex = new InvalidOperationException($"{typeof(TEntity).Name} '{entity.Name}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias."); - Logger.Error>("{EntityTypeName} '{EntityName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.", - ex, + Logger.Error>(ex, "{EntityTypeName} '{EntityName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.", typeof(TEntity).Name, entity.Name); diff --git a/src/Umbraco.Core/Persistence/SqlSyntax/MySqlSyntaxProvider.cs b/src/Umbraco.Core/Persistence/SqlSyntax/MySqlSyntaxProvider.cs index e0eaa46048..32eee8a56d 100644 --- a/src/Umbraco.Core/Persistence/SqlSyntax/MySqlSyntaxProvider.cs +++ b/src/Umbraco.Core/Persistence/SqlSyntax/MySqlSyntaxProvider.cs @@ -385,7 +385,7 @@ ORDER BY TABLE_NAME, INDEX_NAME", } catch (Exception ex) { - _logger.Error("Error querying for lower_case support", ex); + _logger.Error(ex, "Error querying for lower_case support"); } finally { diff --git a/src/Umbraco.Core/Persistence/UmbracoDatabase.cs b/src/Umbraco.Core/Persistence/UmbracoDatabase.cs index 3b3122299e..64e4c0adca 100644 --- a/src/Umbraco.Core/Persistence/UmbracoDatabase.cs +++ b/src/Umbraco.Core/Persistence/UmbracoDatabase.cs @@ -192,7 +192,7 @@ namespace Umbraco.Core.Persistence protected override void OnException(Exception ex) { - _logger.Error("Exception ({InstanceId}).", ex, InstanceId); + _logger.Error(ex, "Exception ({InstanceId}).", InstanceId); _logger.Debug("At:\r\n{StackTrace}", Environment.StackTrace); if (EnableSqlTrace == false) _logger.Debug("Sql:\r\n{Sql}", CommandToString(LastSQL, LastArgs)); diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs index 8e63a236f8..2131764ad6 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs @@ -100,7 +100,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters } catch (Exception ex) { - Current.Logger.Error("Could not parse the string '{JsonString}' to a json object", ex, sourceString); + Current.Logger.Error(ex, "Could not parse the string '{JsonString}' to a json object", sourceString); } } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs index 29b3802e45..79cb748960 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs @@ -43,7 +43,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters catch (Exception ex) { // cannot deserialize, assume it may be a raw image url - Current.Logger.Error("Could not deserialize string '{JsonString}' into an image cropper value.", ex, sourceString); + Current.Logger.Error(ex, "Could not deserialize string '{JsonString}' into an image cropper value.", sourceString); value = new ImageCropperValue { Src = sourceString }; } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs index ff4ccb8260..d4cee4762f 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs @@ -57,7 +57,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters } catch (Exception ex) { - Current.Logger.Error("Could not parse the string '{JsonString}' to a json object", ex, sourceString); + Current.Logger.Error(ex, "Could not parse the string '{JsonString}' to a json object", sourceString); } } diff --git a/src/Umbraco.Core/Publishing/ScheduledPublisher.cs b/src/Umbraco.Core/Publishing/ScheduledPublisher.cs index a7d6c4fad9..73cc752508 100644 --- a/src/Umbraco.Core/Publishing/ScheduledPublisher.cs +++ b/src/Umbraco.Core/Publishing/ScheduledPublisher.cs @@ -46,16 +46,16 @@ namespace Umbraco.Core.Publishing _logger.Debug("Result of publish attempt: {PublishResult}", result.Result); if (result.Success == false) { - _logger.Error("Error publishing node {NodeId}", null, d.Id); + _logger.Error(null, "Error publishing node {NodeId}", d.Id); } else { counter++; } } - catch (Exception ee) + catch (Exception ex) { - _logger.Error("Error publishing node {NodeId}", ee, d.Id); + _logger.Error(ex, "Error publishing node {NodeId}", d.Id); throw; } } @@ -74,9 +74,9 @@ namespace Umbraco.Core.Publishing counter++; } } - catch (Exception ee) + catch (Exception ex) { - _logger.Error("Error unpublishing node {NodeId}", ee, d.Id); + _logger.Error(ex, "Error unpublishing node {NodeId}", d.Id); throw; } } diff --git a/src/Umbraco.Core/Security/MembershipProviderBase.cs b/src/Umbraco.Core/Security/MembershipProviderBase.cs index ea9ce4458a..0c8461c2f2 100644 --- a/src/Umbraco.Core/Security/MembershipProviderBase.cs +++ b/src/Umbraco.Core/Security/MembershipProviderBase.cs @@ -281,7 +281,7 @@ namespace Umbraco.Core.Security if ((PasswordFormat == MembershipPasswordFormat.Hashed) && EnablePasswordRetrieval) { var ex = new ProviderException("Provider can not retrieve a hashed password"); - Current.Logger.Error("Cannot specify a Hashed password format with the enabledPasswordRetrieval option set to true", ex); + Current.Logger.Error(ex, "Cannot specify a Hashed password format with the enabledPasswordRetrieval option set to true"); throw ex; } diff --git a/src/Umbraco.Core/Services/Implement/ContentService.cs b/src/Umbraco.Core/Services/Implement/ContentService.cs index 3a027925c1..0bb00ef5a4 100644 --- a/src/Umbraco.Core/Services/Implement/ContentService.cs +++ b/src/Umbraco.Core/Services/Implement/ContentService.cs @@ -1240,11 +1240,11 @@ namespace Umbraco.Core.Services.Implement d.PublishCulture(); // fixme variants? result = SaveAndPublish(d, userId: d.WriterId); if (result.Success == false) - Logger.Error("Failed to publish document id={DocumentId}, reason={Reason}.", null, d.Id, result.Result); + Logger.Error(null, "Failed to publish document id={DocumentId}, reason={Reason}.", d.Id, result.Result); } catch (Exception e) { - Logger.Error("Failed to publish document id={DocumentId}, an exception was thrown.", e, d.Id); + Logger.Error(e, "Failed to publish document id={DocumentId}, an exception was thrown.", d.Id); throw; } yield return result; @@ -1256,11 +1256,11 @@ namespace Umbraco.Core.Services.Implement d.ExpireDate = null; var result = Unpublish(d, userId: d.WriterId); if (result.Success == false) - Logger.Error("Failed to unpublish document id={DocumentId}, reason={Reason}.", null, d.Id, result.Result); + Logger.Error(null, "Failed to unpublish document id={DocumentId}, reason={Reason}.", d.Id, result.Result); } catch (Exception e) { - Logger.Error("Failed to unpublish document id={DocumentId}, an exception was thrown.", e, d.Id); + Logger.Error(e, "Failed to unpublish document id={DocumentId}, an exception was thrown.", d.Id); throw; } } @@ -1439,7 +1439,7 @@ namespace Umbraco.Core.Services.Implement // fixme not going to work, do it differently _mediaFileSystem.DeleteFiles(args.MediaFilesToDelete, // remove flagged files - (file, e) => Logger.Error("An error occurred while deleting file attached to nodes: {File}", e, file)); + (file, e) => Logger.Error(e, "An error occurred while deleting file attached to nodes: {File}", file)); } } diff --git a/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs b/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs index 23d5fffb03..3b3f90a412 100644 --- a/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs +++ b/src/Umbraco.Core/Services/Implement/LocalizedTextServiceFileSources.cs @@ -204,7 +204,7 @@ namespace Umbraco.Core.Services.Implement } catch (Exception ex) { - _logger.Error("Could not load file into XML {File}", ex, supplementaryFile.File.FullName); + _logger.Error(ex, "Could not load file into XML {File}", supplementaryFile.File.FullName); continue; } diff --git a/src/Umbraco.Core/Services/Implement/MediaService.cs b/src/Umbraco.Core/Services/Implement/MediaService.cs index 27bf36328f..8f6a1c6000 100644 --- a/src/Umbraco.Core/Services/Implement/MediaService.cs +++ b/src/Umbraco.Core/Services/Implement/MediaService.cs @@ -892,7 +892,7 @@ namespace Umbraco.Core.Services.Implement scope.Events.Dispatch(Deleted, this, args); _mediaFileSystem.DeleteFiles(args.MediaFilesToDelete, // remove flagged files - (file, e) => Logger.Error("An error occurred while deleting file attached to nodes: {File}", e, file)); + (file, e) => Logger.Error(e, "An error occurred while deleting file attached to nodes: {File}", file)); } } diff --git a/src/Umbraco.Core/Services/Implement/MemberService.cs b/src/Umbraco.Core/Services/Implement/MemberService.cs index c42007e254..288809bf33 100644 --- a/src/Umbraco.Core/Services/Implement/MemberService.cs +++ b/src/Umbraco.Core/Services/Implement/MemberService.cs @@ -930,7 +930,7 @@ namespace Umbraco.Core.Services.Implement // fixme - this is MOOT because the event will not trigger immediately // it's been refactored already (think it's the dispatcher that deals with it?) _mediaFileSystem.DeleteFiles(args.MediaFilesToDelete, // remove flagged files - (file, e) => Logger.Error("An error occurred while deleting file attached to nodes: {File}", e, file)); + (file, e) => Logger.Error(e, "An error occurred while deleting file attached to nodes: {File}", file)); } #endregion diff --git a/src/Umbraco.Core/Services/Implement/NotificationService.cs b/src/Umbraco.Core/Services/Implement/NotificationService.cs index 0372d973bc..3afb7c3777 100644 --- a/src/Umbraco.Core/Services/Implement/NotificationService.cs +++ b/src/Umbraco.Core/Services/Implement/NotificationService.cs @@ -633,7 +633,7 @@ namespace Umbraco.Core.Services.Implement } catch (Exception ex) { - _logger.Error("An error occurred sending notification", ex); + _logger.Error(ex, "An error occurred sending notification"); s.Dispose(); s = new SmtpClient(); } diff --git a/src/Umbraco.Core/Services/Implement/PackagingService.cs b/src/Umbraco.Core/Services/Implement/PackagingService.cs index 3d4d00e9a4..ef22861947 100644 --- a/src/Umbraco.Core/Services/Implement/PackagingService.cs +++ b/src/Umbraco.Core/Services/Implement/PackagingService.cs @@ -491,7 +491,7 @@ namespace Umbraco.Core.Services.Implement var tryCreateFolder = _contentTypeService.CreateContainer(-1, rootFolder); if (tryCreateFolder == false) { - _logger.Error("Could not create folder: {FolderName}", tryCreateFolder.Exception, rootFolder); + _logger.Error(tryCreateFolder.Exception, "Could not create folder: {FolderName}", rootFolder); throw tryCreateFolder.Exception; } var rootFolderId = tryCreateFolder.Result.Entity.Id; @@ -525,7 +525,7 @@ namespace Umbraco.Core.Services.Implement var tryCreateFolder = _contentTypeService.CreateContainer(current.Id, folderName); if (tryCreateFolder == false) { - _logger.Error("Could not create folder: {FolderName}", tryCreateFolder.Exception, folderName); + _logger.Error(tryCreateFolder.Exception, "Could not create folder: {FolderName}", folderName); throw tryCreateFolder.Exception; } return _contentTypeService.GetContainer(tryCreateFolder.Result.Entity.Id); @@ -949,7 +949,7 @@ namespace Umbraco.Core.Services.Implement var tryCreateFolder = _dataTypeService.CreateContainer(-1, rootFolder); if (tryCreateFolder == false) { - _logger.Error("Could not create folder: {FolderName}", tryCreateFolder.Exception, rootFolder); + _logger.Error(tryCreateFolder.Exception, "Could not create folder: {FolderName}", rootFolder); throw tryCreateFolder.Exception; } current = _dataTypeService.GetContainer(tryCreateFolder.Result.Entity.Id); @@ -982,7 +982,7 @@ namespace Umbraco.Core.Services.Implement var tryCreateFolder = _dataTypeService.CreateContainer(current.Id, folderName); if (tryCreateFolder == false) { - _logger.Error("Could not create folder: {FolderName}", tryCreateFolder.Exception, folderName); + _logger.Error(tryCreateFolder.Exception, "Could not create folder: {FolderName}", folderName); throw tryCreateFolder.Exception; } return _dataTypeService.GetContainer(tryCreateFolder.Result.Entity.Id); diff --git a/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs b/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs index 6f89f1233e..20f9276ba1 100644 --- a/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs +++ b/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs @@ -352,8 +352,7 @@ namespace Umbraco.Core.Sync } catch (JsonException ex) { - Logger.Error("Failed to deserialize instructions ({DtoId}: '{DtoInstructions}').", - ex, + Logger.Error(ex, "Failed to deserialize instructions ({DtoId}: '{DtoInstructions}').", dto.Id, dto.Instructions); @@ -412,8 +411,8 @@ namespace Umbraco.Core.Sync catch (Exception ex) { Logger.Error( - "DISTRIBUTED CACHE IS NOT UPDATED. Failed to execute instructions ({DtoId}: '{DtoInstructions}'). Instruction is being skipped/ignored", ex, + "DISTRIBUTED CACHE IS NOT UPDATED. Failed to execute instructions ({DtoId}: '{DtoInstructions}'). Instruction is being skipped/ignored", dto.Id, dto.Instructions); diff --git a/src/Umbraco.Core/UmbracoApplicationBase.cs b/src/Umbraco.Core/UmbracoApplicationBase.cs index 91d390b308..c461d9f824 100644 --- a/src/Umbraco.Core/UmbracoApplicationBase.cs +++ b/src/Umbraco.Core/UmbracoApplicationBase.cs @@ -92,7 +92,7 @@ namespace Umbraco.Core var msg = "Unhandled exception in AppDomain"; if (isTerminating) msg += " (terminating)"; msg += "."; - logger.Error(msg, exception); + logger.Error(exception, msg); }; } @@ -225,7 +225,7 @@ namespace Umbraco.Core // ignore HTTP errors if (exception.GetType() == typeof(HttpException)) return; - Current.Logger.Error("An unhandled exception occurred", exception); + Current.Logger.Error(exception, "An unhandled exception occurred"); } // called by ASP.NET (auto event wireup) at any phase in the application life cycle @@ -248,7 +248,7 @@ namespace Umbraco.Core } catch (Exception ex) { - Current.Logger.Error("Error in {Name} handler.", ex, name); + Current.Logger.Error(ex, "Error in {Name} handler.", name); throw; } } diff --git a/src/Umbraco.Core/UriExtensions.cs b/src/Umbraco.Core/UriExtensions.cs index e579a5158f..d018dddfbf 100644 --- a/src/Umbraco.Core/UriExtensions.cs +++ b/src/Umbraco.Core/UriExtensions.cs @@ -155,7 +155,7 @@ namespace Umbraco.Core } catch (ArgumentException ex) { - Current.Logger.Error(typeof(UriExtensions), "Failed to determine if request was client side", ex); + Current.Logger.Error(typeof(UriExtensions), ex, "Failed to determine if request was client side"); return false; } } diff --git a/src/Umbraco.Examine/UmbracoExamineIndexer.cs b/src/Umbraco.Examine/UmbracoExamineIndexer.cs index 9519668e00..64fd7b5c71 100644 --- a/src/Umbraco.Examine/UmbracoExamineIndexer.cs +++ b/src/Umbraco.Examine/UmbracoExamineIndexer.cs @@ -331,11 +331,11 @@ namespace Umbraco.Examine /// /// overridden for logging /// - /// - protected override void OnIndexingError(IndexingErrorEventArgs e) + /// + protected override void OnIndexingError(IndexingErrorEventArgs ex) { - ProfilingLogger.Logger.Error(GetType(), e.Message, e.InnerException); - base.OnIndexingError(e); + ProfilingLogger.Logger.Error(GetType(), ex.InnerException, ex.Message); + base.OnIndexingError(ex); } /// diff --git a/src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs b/src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs index 8135f35d0b..4c7fc8511b 100644 --- a/src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs +++ b/src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs @@ -6,18 +6,18 @@ namespace Umbraco.Tests.TestHelpers { public class ConsoleLogger : ILogger { - public void Error(Type reporting, string message, Exception exception) + public void Error(Type reporting, Exception exception, string message) { Console.WriteLine("ERROR {0} - {1}", reporting.Name, message); Console.WriteLine(exception); } - public void Error(Type reporting, string format, Exception exception = null, params object[] args) + public void Error(Type reporting, Exception exception, string format, params object[] args) { Console.WriteLine("ERROR {0} - {1}", reporting.Name, string.Format(format, args)); Console.WriteLine(exception); } - + public void Warn(Type reporting, string message) { Console.WriteLine("WARN {0} - {1}", reporting.Name, message); diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs index 25a0dc72fa..21f1ce82b2 100644 --- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs +++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs @@ -344,7 +344,7 @@ namespace Umbraco.Tests.TestHelpers } catch (Exception ex) { - Logger.Error("Could not remove the old database file", ex); + Logger.Error(ex, "Could not remove the old database file"); // swallow this exception - that's because a sub class might require further teardown logic onFail?.Invoke(ex); diff --git a/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs b/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs index 480227f251..ea7f3364af 100644 --- a/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs +++ b/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs @@ -237,7 +237,7 @@ namespace Umbraco.Web.Components } catch (Exception ex) { - _logger.Error("Failed to update server record in database.", ex); + _logger.Error(ex, "Failed to update server record in database."); return false; // probably stop if we have an error } } diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 869c12d85b..1bbbd9207e 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -995,7 +995,7 @@ namespace Umbraco.Web.Editors } catch (Exception ex) { - Logger.Error("Could not update content sort order", ex); + Logger.Error(ex, "Could not update content sort order"); throw; } } diff --git a/src/Umbraco.Web/Editors/ContentTypeController.cs b/src/Umbraco.Web/Editors/ContentTypeController.cs index a2c2642bcb..ea385ceba6 100644 --- a/src/Umbraco.Web/Editors/ContentTypeController.cs +++ b/src/Umbraco.Web/Editors/ContentTypeController.cs @@ -487,7 +487,7 @@ namespace Umbraco.Web.Editors } catch (Exception ex) { - Current.Logger.Error("Error cleaning up temporary udt file in App_Data: {File}", ex, filePath); + Current.Logger.Error(ex, "Error cleaning up temporary udt file in App_Data: {File}", filePath); } return Request.CreateResponse(HttpStatusCode.OK); diff --git a/src/Umbraco.Web/Editors/DashboardController.cs b/src/Umbraco.Web/Editors/DashboardController.cs index 3faa30d084..85ba534dfd 100644 --- a/src/Umbraco.Web/Editors/DashboardController.cs +++ b/src/Umbraco.Web/Editors/DashboardController.cs @@ -66,7 +66,7 @@ namespace Umbraco.Web.Editors } catch (HttpRequestException ex) { - Logger.Error("Error getting dashboard content from '{Url}'", ex.InnerException ?? ex, url); + Logger.Error(ex.InnerException ?? ex, "Error getting dashboard content from '{Url}'", url); //it's still new JObject() - we return it like this to avoid error codes which triggers UI warnings ApplicationCache.RuntimeCache.InsertCacheItem(key, () => result, new TimeSpan(0, 5, 0)); @@ -107,7 +107,7 @@ namespace Umbraco.Web.Editors } catch (HttpRequestException ex) { - Logger.Error("Error getting dashboard CSS from '{Url}'", ex.InnerException ?? ex, url); + Logger.Error(ex.InnerException ?? ex, "Error getting dashboard CSS from '{Url}'", url); //it's still string.Empty - we return it like this to avoid error codes which triggers UI warnings ApplicationCache.RuntimeCache.InsertCacheItem(key, () => result, new TimeSpan(0, 5, 0)); diff --git a/src/Umbraco.Web/Editors/DictionaryController.cs b/src/Umbraco.Web/Editors/DictionaryController.cs index b7d6479600..7d846e68ec 100644 --- a/src/Umbraco.Web/Editors/DictionaryController.cs +++ b/src/Umbraco.Web/Editors/DictionaryController.cs @@ -90,9 +90,9 @@ namespace Umbraco.Web.Editors return Request.CreateResponse(HttpStatusCode.OK, item.Id); } - catch (Exception exception) + catch (Exception ex) { - Logger.Error(GetType(), "Error creating dictionary with {Name} under {ParentId}", exception, key, parentId); + Logger.Error(GetType(), ex, "Error creating dictionary with {Name} under {ParentId}", key, parentId); return Request.CreateNotificationValidationErrorResponse("Error creating dictionary item"); } } @@ -175,9 +175,9 @@ namespace Umbraco.Web.Editors return model; } - catch (Exception e) + catch (Exception ex) { - Logger.Error(GetType(), "Error saving dictionary with {Name} under {ParentId}", e, dictionary.Name, dictionary.ParentId); + Logger.Error(GetType(), ex, "Error saving dictionary with {Name} under {ParentId}", dictionary.Name, dictionary.ParentId); throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse("Something went wrong saving dictionary")); } } diff --git a/src/Umbraco.Web/Editors/ExamineManagementController.cs b/src/Umbraco.Web/Editors/ExamineManagementController.cs index c4ef00eff8..cfc25454a4 100644 --- a/src/Umbraco.Web/Editors/ExamineManagementController.cs +++ b/src/Umbraco.Web/Editors/ExamineManagementController.cs @@ -171,7 +171,7 @@ namespace Umbraco.Web.Editors { //ensure it's not listening indexer.IndexOperationComplete -= Indexer_IndexOperationComplete; - Logger.Error("An error occurred rebuilding index", ex); + Logger.Error(ex, "An error occurred rebuilding index"); var response = Request.CreateResponse(HttpStatusCode.Conflict); response.Content = new diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs index 7b4054deec..70aa7e4da8 100644 --- a/src/Umbraco.Web/Editors/MediaController.cs +++ b/src/Umbraco.Web/Editors/MediaController.cs @@ -562,7 +562,7 @@ namespace Umbraco.Web.Editors } catch (Exception ex) { - Logger.Error("Could not update media sort order", ex); + Logger.Error(ex, "Could not update media sort order"); throw; } } diff --git a/src/Umbraco.Web/Editors/PackageInstallController.cs b/src/Umbraco.Web/Editors/PackageInstallController.cs index 3c6cd9f46d..d2a0df68ba 100644 --- a/src/Umbraco.Web/Editors/PackageInstallController.cs +++ b/src/Umbraco.Web/Editors/PackageInstallController.cs @@ -72,9 +72,9 @@ namespace Umbraco.Web.Editors installed.Delete(Security.GetUserId().ResultOr(0)); } } - catch (Exception e) + catch (Exception ex) { - Logger.Error("Failed to uninstall.", e); + Logger.Error(ex, "Failed to uninstall."); throw; } @@ -199,13 +199,13 @@ namespace Umbraco.Web.Editors } catch (Exception ex) { - Logger.Error("An error occurred running undo actions", ex); + Logger.Error(ex, "An error occurred running undo actions"); } } } catch (Exception ex) { - Logger.Error("An error occurred running undo actions", ex); + Logger.Error(ex, "An error occurred running undo actions"); } } diff --git a/src/Umbraco.Web/HealthCheck/Checks/Config/ConfigurationService.cs b/src/Umbraco.Web/HealthCheck/Checks/Config/ConfigurationService.cs index c1d71d4180..8b080af88c 100644 --- a/src/Umbraco.Web/HealthCheck/Checks/Config/ConfigurationService.cs +++ b/src/Umbraco.Web/HealthCheck/Checks/Config/ConfigurationService.cs @@ -56,13 +56,13 @@ namespace Umbraco.Web.HealthCheck.Checks.Config Result = string.Format(xmlNode.Value ?? xmlNode.InnerText) }; } - catch (Exception exception) + catch (Exception ex) { - Current.Logger.Error("Error trying to get configuration value", exception); + Current.Logger.Error(ex, "Error trying to get configuration value"); return new ConfigurationServiceResult { Success = false, - Result = _textService.Localize("healthcheck/configurationServiceError", new[] { exception.Message }) + Result = _textService.Localize("healthcheck/configurationServiceError", new[] { ex.Message }) }; } } @@ -102,13 +102,13 @@ namespace Umbraco.Web.HealthCheck.Checks.Config xmlDocument.Save(_configFilePath); return new ConfigurationServiceResult { Success = true }; } - catch (Exception exception) + catch (Exception ex) { - Current.Logger.Error("Error trying to update configuration", exception); + Current.Logger.Error(ex, "Error trying to update configuration"); return new ConfigurationServiceResult { Success = false, - Result = _textService.Localize("healthcheck/configurationServiceError", new[] { exception.Message }) + Result = _textService.Localize("healthcheck/configurationServiceError", new[] { ex.Message }) }; } } diff --git a/src/Umbraco.Web/HealthCheck/HealthCheckController.cs b/src/Umbraco.Web/HealthCheck/HealthCheckController.cs index 14642ac843..6412409488 100644 --- a/src/Umbraco.Web/HealthCheck/HealthCheckController.cs +++ b/src/Umbraco.Web/HealthCheck/HealthCheckController.cs @@ -69,9 +69,9 @@ namespace Umbraco.Web.HealthCheck //Core.Logging.LogHelper.Debug("Running health check: " + check.Name); return check.GetStatus(); } - catch (Exception e) + catch (Exception ex) { - _logger.Error("Exception in health check: " + check.Name, e); + _logger.Error(ex, "Exception in health check: {HealthCheckName}" + check.Name); throw; } } diff --git a/src/Umbraco.Web/HealthCheck/HealthCheckResults.cs b/src/Umbraco.Web/HealthCheck/HealthCheckResults.cs index 6baccf5808..5962f2cabc 100644 --- a/src/Umbraco.Web/HealthCheck/HealthCheckResults.cs +++ b/src/Umbraco.Web/HealthCheck/HealthCheckResults.cs @@ -27,7 +27,7 @@ namespace Umbraco.Web.HealthCheck } catch (Exception ex) { - Logger.Error($"Error running scheduled health check: {t.Name}", ex); + Logger.Error(ex, "Error running scheduled health check: {HealthCheckName}", t.Name); var message = $"Health check failed with exception: {ex.Message}. See logs for details."; return new List { diff --git a/src/Umbraco.Web/ImageCropperTemplateExtensions.cs b/src/Umbraco.Web/ImageCropperTemplateExtensions.cs index 68b0933318..83e4b727b2 100644 --- a/src/Umbraco.Web/ImageCropperTemplateExtensions.cs +++ b/src/Umbraco.Web/ImageCropperTemplateExtensions.cs @@ -447,7 +447,7 @@ namespace Umbraco.Web } catch (Exception ex) { - Current.Logger.Error(typeof(ImageCropperTemplateExtensions), "Could not parse the json string: {Json}", ex, json); + Current.Logger.Error(typeof(ImageCropperTemplateExtensions), ex, "Could not parse the json string: {Json}", json); } } diff --git a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs index 96377e7cb7..6e420cd498 100644 --- a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs +++ b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs @@ -127,7 +127,7 @@ namespace Umbraco.Web.Install.Controllers catch (Exception ex) { - _logger.Error("An error occurred during installation step " + step.Name, ex); + _logger.Error(ex, "An error occurred during installation step {Step}", step.Name); if (ex is TargetInvocationException && ex.InnerException != null) { @@ -217,7 +217,7 @@ namespace Umbraco.Web.Install.Controllers } catch (Exception ex) { - _logger.Error("Checking if step requires execution (" + step.Name + ") failed.", ex); + _logger.Error(ex, "Checking if step requires execution ({Step}) failed.", step.Name); throw; } } @@ -225,7 +225,7 @@ namespace Umbraco.Web.Install.Controllers // executes the step internal InstallSetupResult ExecuteStep(InstallSetupStep step, JToken instruction) { - using (_proflog.TraceDuration("Executing installation step: " + step.Name, "Step completed")) + using (_proflog.TraceDuration("Executing installation step: '{Step}' Step completed", step.Name)) { var model = instruction?.ToObject(step.StepType); var genericStepType = typeof(InstallSetupStep<>); @@ -238,7 +238,7 @@ namespace Umbraco.Web.Install.Controllers } catch (Exception ex) { - _logger.Error("Installation step " + step.Name + " failed.", ex); + _logger.Error(ex, "Installation step {Step} failed.", step.Name); throw; } } diff --git a/src/Umbraco.Web/Install/HttpInstallAuthorizeAttribute.cs b/src/Umbraco.Web/Install/HttpInstallAuthorizeAttribute.cs index 68acdd6cc8..83aa037097 100644 --- a/src/Umbraco.Web/Install/HttpInstallAuthorizeAttribute.cs +++ b/src/Umbraco.Web/Install/HttpInstallAuthorizeAttribute.cs @@ -57,7 +57,7 @@ namespace Umbraco.Web.Install } catch (Exception ex) { - Current.Logger.Error("An error occurred determining authorization", ex); + Current.Logger.Error(ex, "An error occurred determining authorization"); return false; } } diff --git a/src/Umbraco.Web/Install/InstallHelper.cs b/src/Umbraco.Web/Install/InstallHelper.cs index 2c3857cc74..fe8be890fe 100644 --- a/src/Umbraco.Web/Install/InstallHelper.cs +++ b/src/Umbraco.Web/Install/InstallHelper.cs @@ -116,7 +116,7 @@ namespace Umbraco.Web.Install } catch (Exception ex) { - _logger.Error("An error occurred in InstallStatus trying to check upgrades", ex); + _logger.Error(ex, "An error occurred in InstallStatus trying to check upgrades"); } } @@ -183,7 +183,7 @@ namespace Umbraco.Web.Install } catch (AggregateException ex) { - _logger.Error("Could not download list of available starter kits", ex); + _logger.Error(ex, "Could not download list of available starter kits"); } return packages; diff --git a/src/Umbraco.Web/Install/InstallSteps/DatabaseConfigureStep.cs b/src/Umbraco.Web/Install/InstallSteps/DatabaseConfigureStep.cs index aab42dca9e..a54b64733f 100644 --- a/src/Umbraco.Web/Install/InstallSteps/DatabaseConfigureStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/DatabaseConfigureStep.cs @@ -85,7 +85,7 @@ namespace Umbraco.Web.Install.InstallSteps } catch (Exception ex) { - _logger.Error("An error occurred, reconfiguring...", ex); + _logger.Error(ex, "An error occurred, reconfiguring..."); //something went wrong, could not connect so probably need to reconfigure return true; } diff --git a/src/Umbraco.Web/Install/InstallSteps/DatabaseInstallStep.cs b/src/Umbraco.Web/Install/InstallSteps/DatabaseInstallStep.cs index 068f3069bd..c4cad38072 100644 --- a/src/Umbraco.Web/Install/InstallSteps/DatabaseInstallStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/DatabaseInstallStep.cs @@ -59,7 +59,7 @@ namespace Umbraco.Web.Install.InstallSteps else { var ex = new ArgumentNullException(string.Format("ConfigurationManager.ConnectionStrings[{0}]", Constants.System.UmbracoConnectionName), "Install / upgrade did not complete successfully, umbracoDbDSN was not set in the connectionStrings section"); - logger.Error("", ex); + logger.Error(ex, "Install / upgrade did not complete successfully, umbracoDbDSN was not set in the connectionStrings section"); throw ex; } } diff --git a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs index fcc5bd7984..b98b4c4e70 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs @@ -40,8 +40,9 @@ namespace Umbraco.Web.Models.Mapping if (editor == null) { _logger.Error>( - "No property editor found, converting to a Label", - new NullReferenceException("The property editor with alias " + property.PropertyType.PropertyEditorAlias + " does not exist")); + new NullReferenceException("The property editor with alias " + property.PropertyType.PropertyEditorAlias + " does not exist"), + "No property editor '{PropertyEditorAlias}' found, converting to a Label", + property.PropertyType.PropertyEditorAlias); editor = _propertyEditors[Constants.PropertyEditors.Aliases.NoEdit]; } diff --git a/src/Umbraco.Web/Mvc/AdminTokenAuthorizeAttribute.cs b/src/Umbraco.Web/Mvc/AdminTokenAuthorizeAttribute.cs index adb9bf69d8..882cb5624c 100644 --- a/src/Umbraco.Web/Mvc/AdminTokenAuthorizeAttribute.cs +++ b/src/Umbraco.Web/Mvc/AdminTokenAuthorizeAttribute.cs @@ -119,7 +119,7 @@ namespace Umbraco.Web.Mvc } catch (Exception ex) { - Logger.Error("Failed to format passed in token value", ex); + Logger.Error(ex, "Failed to format passed in token value"); return false; } } diff --git a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs index 6183641aaf..2a74b4f05c 100644 --- a/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs @@ -76,7 +76,7 @@ namespace Umbraco.Web.PropertyEditors catch (Exception ex) { if (writeLog) - Logger.Error($"Could not parse image cropper value \"{value}\"", ex); + Logger.Error(ex, "Could not parse image cropper value '{Json}'", value); return null; } } diff --git a/src/Umbraco.Web/PropertyEditors/RteEmbedController.cs b/src/Umbraco.Web/PropertyEditors/RteEmbedController.cs index ff9c9d49e7..9199707d10 100644 --- a/src/Umbraco.Web/PropertyEditors/RteEmbedController.cs +++ b/src/Umbraco.Web/PropertyEditors/RteEmbedController.cs @@ -63,7 +63,7 @@ namespace Umbraco.Web.PropertyEditors } catch(Exception ex) { - Logger.Error(string.Format("Error embedding url {0} - width: {1} height: {2}", url, width, height), ex); + Logger.Error(ex, "Error embedding url {Url} - width: {Width} height: {Height}", url, width, height); result.Status = Status.Error; } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs index 1e8197ec7a..407ea481c4 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs @@ -85,7 +85,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters } catch (Exception ex) { - _logger.Error("Could not parse the string " + sourceString + " to a json object", ex); + _logger.Error(ex, "Could not parse the string '{Json}' to a json object", sourceString); } } @@ -123,7 +123,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters } catch (Exception ex) { - _logger.Error("Could not parse the string " + sourceString + " to a json object", ex); + _logger.Error(ex, "Could not parse the string '{Json}' to a json object", sourceString); } } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs index 23670e1601..b3b3919278 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs @@ -158,7 +158,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters } catch (Exception ex) { - _logger.Error("Could not parse the string {SourceString} to a json object", ex, sourceString); + _logger.Error(ex, "Could not parse the string {Json} to a json object", sourceString); } } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index d42860480a..45af51db0f 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -186,9 +186,9 @@ namespace Umbraco.Web.PublishedCache.NuCache LockAndLoadDomains(); } - catch (Exception e) + catch (Exception ex) { - _logger.Error("Panic, exception while loading cache data.", e); + _logger.Fatal(ex, "Panic, exception while loading cache data."); } // finaly, cache is ready! diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PreviewContent.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PreviewContent.cs index 36b38b11ac..515fb96679 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PreviewContent.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PreviewContent.cs @@ -40,7 +40,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache } catch (Exception ex) { - Current.Logger.Error($"Could not load preview set {_previewSet} for user {_userId}.", ex); + Current.Logger.Error(ex, "Could not load preview set {PreviewSet} for user {UserId}.", _previewSet, _userId); ClearPreviewSet(); @@ -146,7 +146,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache } catch (Exception ex) { - Current.Logger.Error($"Couldn't delete preview set {file.Name} for user {userId}", ex); + Current.Logger.Error(ex, "Couldn't delete preview set {FileName} for user {UserId}", file.Name, userId); } } diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs index 26542e376a..79ff0c33a8 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedMediaCache.cs @@ -122,13 +122,13 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache //See this thread: http://examine.cdodeplex.com/discussions/264341 //Catch the exception here for the time being, and just fallback to GetMedia //TODO: Need to fix examine in LB scenarios! - Current.Logger.Error("Could not load data from Examine index for media", ex); + Current.Logger.Error(ex, "Could not load data from Examine index for media"); } else if (ex is AlreadyClosedException) { //If the app domain is shutting down and the site is under heavy load the index reader will be closed and it really cannot //be re-opened since the app domain is shutting down. In this case we have no option but to try to load the data from the db. - Current.Logger.Error("Could not load data from Examine index for media, the app domain is most likely in a shutdown state", ex); + Current.Logger.Error(ex, "Could not load data from Examine index for media, the app domain is most likely in a shutdown state"); } else throw; } @@ -306,13 +306,13 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache //See this thread: http://examine.cdodeplex.com/discussions/264341 //Catch the exception here for the time being, and just fallback to GetMedia //TODO: Need to fix examine in LB scenarios! - Current.Logger.Error("Could not load data from Examine index for media", ex); + Current.Logger.Error(ex, "Could not load data from Examine index for media"); } else if (ex is AlreadyClosedException) { //If the app domain is shutting down and the site is under heavy load the index reader will be closed and it really cannot //be re-opened since the app domain is shutting down. In this case we have no option but to try to load the data from the db. - Current.Logger.Error("Could not load data from Examine index for media, the app domain is most likely in a shutdown state", ex); + Current.Logger.Error(ex, "Could not load data from Examine index for media, the app domain is most likely in a shutdown state"); } else throw; } diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs index 340a40bb97..7d773824d5 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs @@ -409,9 +409,9 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache } dtd.Append(dtdInner); } - catch (Exception exception) + catch (Exception ex) { - Current.Logger.Error("Failed to build a DTD for the Xml cache.", exception); + Current.Logger.Error(ex, "Failed to build a DTD for the Xml cache."); } dtd.AppendLine("]>"); @@ -696,12 +696,12 @@ AND (umbracoNode.id=@id)"; Current.Logger.Info("Saved Xml to file."); } - catch (Exception e) + catch (Exception ex) { // if something goes wrong remove the file DeleteXmlFile(); - Current.Logger.Error("Failed to save Xml to file.", e); + Current.Logger.Error(ex, "Failed to save Xml to file '{FileName}'.", _xmlFileName); } } @@ -736,12 +736,12 @@ AND (umbracoNode.id=@id)"; Current.Logger.Info("Saved Xml to file."); } - catch (Exception e) + catch (Exception ex) { // if something goes wrong remove the file DeleteXmlFile(); - Current.Logger.Error("Failed to save Xml to file.", e); + Current.Logger.Error(ex, "Failed to save Xml to file '{FileName}'.", _xmlFileName); } } @@ -796,9 +796,9 @@ AND (umbracoNode.id=@id)"; Current.Logger.Warn("Failed to load Xml, file does not exist."); return null; } - catch (Exception e) + catch (Exception ex) { - Current.Logger.Error("Failed to load Xml from file.", e); + Current.Logger.Error(ex, "Failed to load Xml from file '{FileName}'.", _xmlFileName); try { DeleteXmlFile(); diff --git a/src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs b/src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs index bcf89349ef..1a0e5ef873 100644 --- a/src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs +++ b/src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs @@ -107,7 +107,7 @@ namespace Umbraco.Web.Routing } catch (Exception ex) { - Current.Logger.Error("Could not parse xpath expression: " + errorPage.ContentXPath, ex); + Current.Logger.Error(ex, "Could not parse xpath expression: {ContentXPath}", errorPage.ContentXPath); return null; } } diff --git a/src/Umbraco.Web/Routing/UrlProviderExtensions.cs b/src/Umbraco.Web/Routing/UrlProviderExtensions.cs index b8671b5735..2be0dce096 100644 --- a/src/Umbraco.Web/Routing/UrlProviderExtensions.cs +++ b/src/Umbraco.Web/Routing/UrlProviderExtensions.cs @@ -66,9 +66,9 @@ namespace Umbraco.Web.Routing { url = umbracoContext.UrlProvider.GetUrl(content.Id, culture); } - catch (Exception e) + catch (Exception ex) { - logger.Error("GetUrl exception.", e); + logger.Error(ex, "GetUrl exception."); url = "#ex"; } diff --git a/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs b/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs index 421b97d7d2..ed08a0ddb6 100644 --- a/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs +++ b/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs @@ -387,9 +387,9 @@ namespace Umbraco.Web.Scheduling { await RunAsync(bgTask, _cancelTokenSource.Token).ConfigureAwait(false); } - catch (Exception e) + catch (Exception ex) { - _logger.Error("{LogPrefix} Task runner exception", e, _logPrefix); + _logger.Error(ex, "{LogPrefix} Task runner exception", _logPrefix); } // done @@ -537,7 +537,7 @@ namespace Umbraco.Web.Scheduling catch (Exception ex) { - _logger.Error("{LogPrefix} Task has failed", ex, _logPrefix); + _logger.Error(ex, "{LogPrefix} Task has failed", _logPrefix); } } @@ -580,7 +580,7 @@ namespace Umbraco.Web.Scheduling } catch (Exception ex) { - _logger.Error(_logPrefix + name + " exception occurred", ex); + _logger.Error(ex, "{LogPrefix} {Name} exception occurred", _logPrefix, name); } } diff --git a/src/Umbraco.Web/Scheduling/KeepAlive.cs b/src/Umbraco.Web/Scheduling/KeepAlive.cs index 74c9f79d42..530fbc0677 100644 --- a/src/Umbraco.Web/Scheduling/KeepAlive.cs +++ b/src/Umbraco.Web/Scheduling/KeepAlive.cs @@ -63,9 +63,9 @@ namespace Umbraco.Web.Scheduling var result = await wc.SendAsync(request, token); } } - catch (Exception e) + catch (Exception ex) { - _logger.Error(string.Format("Failed (at \"{0}\").", umbracoAppUrl), e); + _logger.Error(ex, "Failed (at '{UmbracoAppUrl}').", umbracoAppUrl); } } diff --git a/src/Umbraco.Web/Scheduling/LogScrubber.cs b/src/Umbraco.Web/Scheduling/LogScrubber.cs index 9edd203856..5fcdd4d6dc 100644 --- a/src/Umbraco.Web/Scheduling/LogScrubber.cs +++ b/src/Umbraco.Web/Scheduling/LogScrubber.cs @@ -41,9 +41,9 @@ namespace Umbraco.Web.Scheduling if (settings.Logging.MaxLogAge > -1) maximumAge = settings.Logging.MaxLogAge; } - catch (Exception e) + catch (Exception ex) { - _logger.Error("Unable to locate a log scrubbing maximum age. Defaulting to 24 hours.", e); + _logger.Error(ex, "Unable to locate a log scrubbing maximum age. Defaulting to 24 hours."); } return maximumAge; @@ -57,9 +57,9 @@ namespace Umbraco.Web.Scheduling if (settings.Logging.CleaningMiliseconds > -1) interval = settings.Logging.CleaningMiliseconds; } - catch (Exception e) + catch (Exception ex) { - logger.Error("Unable to locate a log scrubbing interval. Defaulting to 4 hours.", e); + logger.Error(ex, "Unable to locate a log scrubbing interval. Defaulting to 4 hours."); } return interval; } diff --git a/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs b/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs index fa5fc452db..ae2031dac6 100644 --- a/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs +++ b/src/Umbraco.Web/Scheduling/ScheduledPublishing.cs @@ -62,9 +62,9 @@ namespace Umbraco.Web.Scheduling var publisher = new ScheduledPublisher(_contentService, _logger, _userService); var count = publisher.CheckPendingAndProcess(); } - catch (Exception e) + catch (Exception ex) { - _logger.Error("Failed.", e); + _logger.Error(ex, "Failed."); } return true; // repeat diff --git a/src/Umbraco.Web/Scheduling/ScheduledTasks.cs b/src/Umbraco.Web/Scheduling/ScheduledTasks.cs index dc0f77e0fc..9644ad864c 100644 --- a/src/Umbraco.Web/Scheduling/ScheduledTasks.cs +++ b/src/Umbraco.Web/Scheduling/ScheduledTasks.cs @@ -82,7 +82,7 @@ namespace Umbraco.Web.Scheduling } catch (Exception ex) { - _logger.Error("An error occurred calling web task for url: " + url, ex); + _logger.Error(ex, "An error occurred calling web task for url: {Url}", url); } return false; } @@ -113,9 +113,9 @@ namespace Umbraco.Web.Scheduling { await ProcessTasksAsync(token); } - catch (Exception ee) + catch (Exception ex) { - _logger.Error("Error executing scheduled task", ee); + _logger.Error(ex, "Error executing scheduled task"); } } diff --git a/src/Umbraco.Web/Search/ExamineComponent.cs b/src/Umbraco.Web/Search/ExamineComponent.cs index 627166bbb9..ff7d0c8dc4 100644 --- a/src/Umbraco.Web/Search/ExamineComponent.cs +++ b/src/Umbraco.Web/Search/ExamineComponent.cs @@ -133,9 +133,9 @@ namespace Umbraco.Web.Search // rebuilds any empty indexes RebuildIndexes(true, _examineManager, logger); } - catch (Exception e) + catch (Exception ex) { - logger.Error("Failed to rebuild empty indexes.", e); + logger.Error(ex, "Failed to rebuild empty indexes."); } }); bg.Start(); @@ -219,9 +219,9 @@ namespace Umbraco.Web.Search i.DocumentWriting += grid.DocumentWriting; } } - catch (Exception e) + catch (Exception ex) { - logger.Error("Failed to bind grid property editor.", e); + logger.Error(ex, "Failed to bind grid property editor."); } } diff --git a/src/Umbraco.Web/Security/Identity/AuthenticationOptionsExtensions.cs b/src/Umbraco.Web/Security/Identity/AuthenticationOptionsExtensions.cs index 08e367eeeb..20f93f44a6 100644 --- a/src/Umbraco.Web/Security/Identity/AuthenticationOptionsExtensions.cs +++ b/src/Umbraco.Web/Security/Identity/AuthenticationOptionsExtensions.cs @@ -108,7 +108,7 @@ namespace Umbraco.Web.Security.Identity } catch (System.Exception ex) { - Current.Logger.Error(typeof (AuthenticationOptionsExtensions), "Could not read AuthenticationOptions properties", ex); + Current.Logger.Error(typeof (AuthenticationOptionsExtensions), ex, "Could not read AuthenticationOptions properties"); } } else diff --git a/src/Umbraco.Web/Trees/LegacyTreeController.cs b/src/Umbraco.Web/Trees/LegacyTreeController.cs index 155e7db3e7..87035e0632 100644 --- a/src/Umbraco.Web/Trees/LegacyTreeController.cs +++ b/src/Umbraco.Web/Trees/LegacyTreeController.cs @@ -38,9 +38,8 @@ namespace Umbraco.Web.Trees var attempt = tree.TryLoadFromLegacyTree(id, queryStrings, Url, tree.ApplicationAlias); if (attempt.Success == false) { - var msg = "Could not render tree " + queryStrings.GetRequiredString("treeType") + " for node id " + id; - Logger.Error(msg, attempt.Exception); - throw new ApplicationException(msg); + Logger.Error(attempt.Exception, "Could not render tree {TreeType} for node id {NodeId}", queryStrings.GetRequiredString("treeType"), id); + throw new ApplicationException("Could not render tree " + queryStrings.GetRequiredString("treeType") + " for node id " + id); } return attempt.Result; @@ -65,9 +64,8 @@ namespace Umbraco.Web.Trees var attempt = tree.TryGetMenuFromLegacyTreeRootNode(queryStrings, Url); if (attempt.Success == false) { - var msg = "Could not render menu for root node for treeType " + queryStrings.GetRequiredString("treeType"); - Logger.Error(msg, attempt.Exception); - throw new ApplicationException(msg); + Logger.Error(attempt.Exception, "Could not render menu for root node for treeType {TreeType}", queryStrings.GetRequiredString("treeType")); + throw new ApplicationException("Could not render menu for root node for treeType " + queryStrings.GetRequiredString("treeType")); } foreach (var menuItem in attempt.Result.Items) @@ -81,9 +79,8 @@ namespace Umbraco.Web.Trees var attempt = tree.TryGetMenuFromLegacyTreeNode(parentId, id, queryStrings, Url); if (attempt.Success == false) { - var msg = "Could not render menu for treeType " + queryStrings.GetRequiredString("treeType") + " for node id " + parentId; - Logger.Error(msg, attempt.Exception); - throw new ApplicationException(msg); + Logger.Error(attempt.Exception, "Could not render menu for treeType {TreeType} for node id {ParentNodeId}", queryStrings.GetRequiredString("treeType"), parentId); + throw new ApplicationException("Could not render menu for treeType " + queryStrings.GetRequiredString("treeType") + " for node id " + parentId); } foreach (var menuItem in attempt.Result.Items) { diff --git a/src/Umbraco.Web/Trees/LegacyTreeJavascript.cs b/src/Umbraco.Web/Trees/LegacyTreeJavascript.cs index 0ce362a481..0ae9916d4b 100644 --- a/src/Umbraco.Web/Trees/LegacyTreeJavascript.cs +++ b/src/Umbraco.Web/Trees/LegacyTreeJavascript.cs @@ -34,7 +34,7 @@ namespace Umbraco.Web.Trees } catch (Exception ex) { - Current.Logger.Error(typeof(LegacyTreeJavascript), "Could not load the JS from the legacy tree {TreeAlias}", ex, bTree.TreeAlias); + Current.Logger.Error(typeof(LegacyTreeJavascript), ex, "Could not load the JS from the legacy tree {TreeAlias}", bTree.TreeAlias); } } @@ -64,9 +64,9 @@ namespace Umbraco.Web.Trees } } } - catch (Exception ee) + catch (Exception ex) { - Current.Logger.Error(typeof(LegacyTreeJavascript), "Error initializing tree action", ee); + Current.Logger.Error(typeof(LegacyTreeJavascript), ex, "Error initializing tree action"); } } diff --git a/src/Umbraco.Web/UI/CdfLogger.cs b/src/Umbraco.Web/UI/CdfLogger.cs index ab2ec18197..2a36a52376 100644 --- a/src/Umbraco.Web/UI/CdfLogger.cs +++ b/src/Umbraco.Web/UI/CdfLogger.cs @@ -36,12 +36,12 @@ namespace Umbraco.Web.UI public void Error(string msg, Exception ex) { - _logger.Error(msg, ex); + _logger.Error(ex, msg); } public void Fatal(string msg, Exception ex) { - _logger.Error(msg, ex); + _logger.Error(ex, msg); } } } diff --git a/src/Umbraco.Web/UI/Pages/UmbracoEnsuredPage.cs b/src/Umbraco.Web/UI/Pages/UmbracoEnsuredPage.cs index 48bb3e6881..a8cb93c704 100644 --- a/src/Umbraco.Web/UI/Pages/UmbracoEnsuredPage.cs +++ b/src/Umbraco.Web/UI/Pages/UmbracoEnsuredPage.cs @@ -102,7 +102,7 @@ namespace Umbraco.Web.UI.Pages if (!Security.ValidateUserApp(CurrentApp)) { var ex = new SecurityException(String.Format("The current user doesn't have access to the section/app '{0}'", CurrentApp)); - Current.Logger.Error(String.Format("Tried to access '{0}'", CurrentApp), ex); + Current.Logger.Error(ex, "Tried to access '{CurrentApp}'", CurrentApp); throw ex; } diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index 14cebabdac..2094781ee0 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -492,7 +492,7 @@ namespace Umbraco.Web } catch (Exception ex) { - Logger.Error("Could not dispose item with key " + k, ex); + Logger.Error(ex, "Could not dispose item with key {Key}", k); } try { @@ -500,7 +500,7 @@ namespace Umbraco.Web } catch (Exception ex) { - Logger.Error("Could not dispose item key " + k, ex); + Logger.Error(ex, "Could not dispose item key {Key}", k); } } } @@ -665,7 +665,7 @@ namespace Umbraco.Web } catch (Exception ex) { - Logger.Error("Could not add reserved path route", ex); + Logger.Error(ex, "Could not add reserved path route"); } } diff --git a/src/Umbraco.Web/WebApi/Filters/AngularAntiForgeryHelper.cs b/src/Umbraco.Web/WebApi/Filters/AngularAntiForgeryHelper.cs index 92589fc370..a0bbeac851 100644 --- a/src/Umbraco.Web/WebApi/Filters/AngularAntiForgeryHelper.cs +++ b/src/Umbraco.Web/WebApi/Filters/AngularAntiForgeryHelper.cs @@ -59,7 +59,7 @@ namespace Umbraco.Web.WebApi.Filters } catch (Exception ex) { - Current.Logger.Error(typeof(AngularAntiForgeryHelper), "Could not validate XSRF token", ex); + Current.Logger.Error(typeof(AngularAntiForgeryHelper), ex, "Could not validate XSRF token"); return false; } return true; diff --git a/src/Umbraco.Web/WebApi/Filters/FileUploadCleanupFilterAttribute.cs b/src/Umbraco.Web/WebApi/Filters/FileUploadCleanupFilterAttribute.cs index 9b2a533273..b60545e3cb 100644 --- a/src/Umbraco.Web/WebApi/Filters/FileUploadCleanupFilterAttribute.cs +++ b/src/Umbraco.Web/WebApi/Filters/FileUploadCleanupFilterAttribute.cs @@ -66,7 +66,7 @@ namespace Umbraco.Web.WebApi.Filters } catch (System.Exception ex) { - Current.Logger.Error("Could not delete temp file " + f.TempFilePath, ex); + Current.Logger.Error(ex, "Could not delete temp file {FileName}", f.TempFilePath); } } } @@ -98,7 +98,7 @@ namespace Umbraco.Web.WebApi.Filters } catch (System.Exception ex) { - Current.Logger.Error("Could not acquire actionExecutedContext.Response.Content", ex); + Current.Logger.Error(ex, "Could not acquire actionExecutedContext.Response.Content"); return; } @@ -121,7 +121,7 @@ namespace Umbraco.Web.WebApi.Filters tempFolders.Add(dir); } - Current.Logger.Debug("Removing temp file " + f.TempFilePath); + Current.Logger.Debug("Removing temp file {FileName}", f.TempFilePath); try { @@ -129,7 +129,7 @@ namespace Umbraco.Web.WebApi.Filters } catch (System.Exception ex) { - Current.Logger.Error("Could not delete temp file " + f.TempFilePath, ex); + Current.Logger.Error(ex, "Could not delete temp file {FileName}", f.TempFilePath); } //clear out the temp path so it's not returned in the response @@ -148,12 +148,12 @@ namespace Umbraco.Web.WebApi.Filters } else { - Current.Logger.Warn("The actionExecutedContext.Request.Content.Value is not IHaveUploadedFiles, it is " + objectContent.Value.GetType()); + Current.Logger.Warn("The actionExecutedContext.Request.Content.Value is not IHaveUploadedFiles, it is {ObjectType}", objectContent.Value.GetType()); } } else { - Current.Logger.Warn("The actionExecutedContext.Request.Content is not ObjectContent, it is " + actionExecutedContext.Request.Content.GetType()); + Current.Logger.Warn("The actionExecutedContext.Request.Content is not ObjectContent, it is {RequestObjectType}", actionExecutedContext.Request.Content.GetType()); } } @@ -171,7 +171,7 @@ namespace Umbraco.Web.WebApi.Filters } catch (System.Exception ex) { - Current.Logger.Error("Could not delete temp file " + file, ex); + Current.Logger.Error(ex, "Could not delete temp file {FileName}", file); } } } diff --git a/src/Umbraco.Web/WebApi/UnhandledExceptionLogger.cs b/src/Umbraco.Web/WebApi/UnhandledExceptionLogger.cs index df8e1c2ac8..fddb95afbe 100644 --- a/src/Umbraco.Web/WebApi/UnhandledExceptionLogger.cs +++ b/src/Umbraco.Web/WebApi/UnhandledExceptionLogger.cs @@ -32,7 +32,7 @@ namespace Umbraco.Web.WebApi var requestUrl = context.ExceptionContext.ControllerContext.Request.RequestUri.AbsoluteUri; var controllerType = context.ExceptionContext.ActionContext.ControllerContext.Controller.GetType(); - _logger.Error(controllerType, "Unhandled controller exception occurred for request '{RequestUrl}'", context.Exception, requestUrl); + _logger.Error(controllerType, context.Exception, "Unhandled controller exception occurred for request '{RequestUrl}'", requestUrl); } } diff --git a/src/Umbraco.Web/_Legacy/Actions/Action.cs b/src/Umbraco.Web/_Legacy/Actions/Action.cs index 99022eb16d..388a5735fd 100644 --- a/src/Umbraco.Web/_Legacy/Actions/Action.cs +++ b/src/Umbraco.Web/_Legacy/Actions/Action.cs @@ -81,9 +81,9 @@ namespace Umbraco.Web._Legacy.Actions _actionJsList += string.Format(",\n\tmenuItem(\"{0}\", \"{1}\", \"{2}\", \"{3}\")", action.Letter, icon, Current.Services.TextService.Localize("actions/"+ action.Alias, new[] { language }), action.JsFunctionName); } - catch (Exception ee) + catch (Exception ex) { - Current.Logger.Error("Error registrering action to javascript", ee); + Current.Logger.Error(ex, "Error registrering action to javascript"); } } diff --git a/src/Umbraco.Web/_Legacy/PackageActions/addStringToHtmlElement.cs b/src/Umbraco.Web/_Legacy/PackageActions/addStringToHtmlElement.cs index 8eedd13e06..56ebb76980 100644 --- a/src/Umbraco.Web/_Legacy/PackageActions/addStringToHtmlElement.cs +++ b/src/Umbraco.Web/_Legacy/PackageActions/addStringToHtmlElement.cs @@ -123,7 +123,7 @@ namespace Umbraco.Web._Legacy.PackageActions } catch (Exception ex) { - Current.Logger.Error("An error occurred", ex); + Current.Logger.Error(ex, "An error occurred"); } } else @@ -171,7 +171,7 @@ namespace Umbraco.Web._Legacy.PackageActions } catch (Exception ex) { - Current.Logger.Error("An error occurred", ex); + Current.Logger.Error(ex, "An error occurred"); } } else diff --git a/src/Umbraco.Web/_Legacy/Packager/Installer.cs b/src/Umbraco.Web/_Legacy/Packager/Installer.cs index 87ffa2d665..952f1987a4 100644 --- a/src/Umbraco.Web/_Legacy/Packager/Installer.cs +++ b/src/Umbraco.Web/_Legacy/Packager/Installer.cs @@ -187,9 +187,9 @@ namespace umbraco.cms.businesslogic.packager tempDir = UnPack(fi.FullName, deleteFile); LoadConfig(tempDir); } - catch (Exception exception) + catch (Exception ex) { - Current.Logger.Error(string.Format("Error importing file {0}", fi.FullName), exception); + Current.Logger.Error(ex, "Error importing file {FileName}", fi.FullName); throw; } } @@ -317,9 +317,9 @@ namespace umbraco.cms.businesslogic.packager File.Delete(sourceFile); } } - catch (Exception exception) + catch (Exception ex) { - Current.Logger.Error("Package install error", exception); + Current.Logger.Error(ex, "Package install error"); throw; } @@ -522,9 +522,9 @@ namespace umbraco.cms.businesslogic.packager insPack.Save(); } - catch (Exception exception) + catch (Exception ex) { - Current.Logger.Error("Error installing businesslogic", exception); + Current.Logger.Error(ex, "Error installing businesslogic"); throw; } diff --git a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/InstalledPackage.cs b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/InstalledPackage.cs index a358c69389..c16afa0b84 100644 --- a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/InstalledPackage.cs +++ b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/InstalledPackage.cs @@ -87,7 +87,7 @@ namespace umbraco.cms.businesslogic.packager { } catch (Exception ex) { - Current.Logger.Error("An error occured in isPackagedInstalled", ex); + Current.Logger.Error(ex, "An error occured in isPackagedInstalled"); return false; } } diff --git a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageActions.cs b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageActions.cs index 90645fa121..d1df47cd44 100644 --- a/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageActions.cs +++ b/src/Umbraco.Web/_Legacy/Packager/PackageInstance/PackageActions.cs @@ -34,9 +34,9 @@ namespace umbraco.cms.businesslogic.packager ipa.Execute(packageName, actionXml); } } - catch (Exception ipaExp) + catch (Exception ex) { - Current.Logger.Error(string.Format("Error loading package action '{0}' for package {1}", ipa.Alias(), packageName), ipaExp); + Current.Logger.Error(ex, "Error loading package action '{PackageActionAlias}' for package {PackageName}", ipa.Alias(), packageName); } } } @@ -60,9 +60,9 @@ namespace umbraco.cms.businesslogic.packager ipa.Undo(packageName, actionXml); } } - catch (Exception ipaExp) + catch (Exception ex) { - Current.Logger.Error(string.Format("Error undoing package action '{0}' for package {1}", ipa.Alias(), packageName), ipaExp); + Current.Logger.Error(ex, "Error undoing package action '{PackageActionAlias}' for package {PackageName}", ipa.Alias(), packageName); } } } diff --git a/src/Umbraco.Web/_Legacy/Packager/data.cs b/src/Umbraco.Web/_Legacy/Packager/data.cs index 9353d52461..88cc7a4b54 100644 --- a/src/Umbraco.Web/_Legacy/Packager/data.cs +++ b/src/Umbraco.Web/_Legacy/Packager/data.cs @@ -180,7 +180,7 @@ namespace umbraco.cms.businesslogic.packager } catch (Exception ex) { - Current.Logger.Error("An error occurred in GetAllPackages", ex); + Current.Logger.Error(ex, "An error occurred in GetAllPackages"); } } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/JTreeContextMenu.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/JTreeContextMenu.cs index 267eb7323e..726936f570 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/JTreeContextMenu.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/controls/Tree/JTreeContextMenu.cs @@ -45,9 +45,9 @@ namespace umbraco.controls.Tree } } } - catch (Exception ee) + catch (Exception ex) { - Current.Logger.Error("Error initializing tree action", ee); + Current.Logger.Error(ex, "Error initializing tree action"); } } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dashboard/FeedProxy.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dashboard/FeedProxy.aspx.cs index dd4988f65a..0e21605fbb 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dashboard/FeedProxy.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dashboard/FeedProxy.aspx.cs @@ -47,7 +47,7 @@ namespace dashboardUtilities } else { - Current.Logger.Debug(string.Format("Access to unallowed feedproxy attempted: {0}", requestUri)); + Current.Logger.Debug("Access to unallowed feedproxy attempted: {RequestUrl}", requestUri); } } } @@ -55,7 +55,7 @@ namespace dashboardUtilities } catch (Exception ex) { - Current.Logger.Error("Exception occurred", ex); + Current.Logger.Error(ex, "Exception occurred"); } } } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs index 518138d761..d1a542fac8 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/protectPage.aspx.cs @@ -244,7 +244,7 @@ namespace umbraco.presentation.umbraco.dialogs } catch (Exception ex) { - Current.Logger.Error("An error occurred initializing the protect page editor", ex); + Current.Logger.Error(ex, "An error occurred initializing the protect page editor"); } if (GetProtectionType(documentId) == ProtectionType.Simple) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sendToTranslation.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sendToTranslation.aspx.cs index cfefdda52c..62063863bd 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sendToTranslation.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/sendToTranslation.aspx.cs @@ -182,7 +182,7 @@ namespace umbraco.presentation.dialogs } catch (Exception ex) { - Current.Logger.Error("Error sending translation e-mail", ex); + Current.Logger.Error(ex, "Error sending translation e-mail"); } } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs index ca26c5c08d..f82587a413 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs @@ -137,7 +137,7 @@ namespace umbraco.presentation.webservices } catch (Exception ex) { - Current.Logger.Error("Could not update media sort order", ex); + Current.Logger.Error(ex, "Could not update media sort order"); } } @@ -192,7 +192,7 @@ namespace umbraco.presentation.webservices } catch (Exception ex) { - Current.Logger.Error("Could not update content sort order", ex); + Current.Logger.Error(ex, "Could not update content sort order"); } }