Remove LogError<T> from LoggerExtensions

This commit is contained in:
Nikolaj
2020-09-16 09:40:49 +02:00
parent e870823e81
commit dda6fb12a3
66 changed files with 115 additions and 195 deletions

View File

@@ -47,7 +47,7 @@ namespace Umbraco.Core.Configuration.Grid
}
catch (Exception ex)
{
_logger.LogError<GridEditorsConfig>(ex, "Could not parse the contents of grid.editors.config.js into a JSON array '{Json}", sourceString);
_logger.LogError(ex, "Could not parse the contents of grid.editors.config.js into a JSON array '{Json}", sourceString);
}
}

View File

@@ -61,7 +61,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
}
catch (Exception ex)
{
_logger.LogError<ConfigurationService>(ex, "Error trying to get configuration value");
_logger.LogError(ex, "Error trying to get configuration value");
return new ConfigurationServiceResult
{
Success = false,
@@ -107,7 +107,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
}
catch (Exception ex)
{
_logger.LogError<ConfigurationService>(ex, "Error trying to update configuration");
_logger.LogError(ex, "Error trying to update configuration");
return new ConfigurationServiceResult
{
Success = false,

View File

@@ -51,7 +51,7 @@ namespace Umbraco.Core.IO
}
catch (Exception e)
{
_logger.LogError<MediaFileSystem>(e, "Failed to delete media file '{File}'.", file);
_logger.LogError(e, "Failed to delete media file '{File}'.", file);
}
});
}

View File

@@ -87,11 +87,11 @@ namespace Umbraco.Core.IO
}
catch (UnauthorizedAccessException ex)
{
_logger.LogError<PhysicalFileSystem>(ex, "Not authorized to get directories for '{Path}'", fullPath);
_logger.LogError(ex, "Not authorized to get directories for '{Path}'", fullPath);
}
catch (DirectoryNotFoundException ex)
{
_logger.LogError<PhysicalFileSystem>(ex, "Directory not found for '{Path}'", fullPath);
_logger.LogError(ex, "Directory not found for '{Path}'", fullPath);
}
return Enumerable.Empty<string>();
@@ -123,7 +123,7 @@ namespace Umbraco.Core.IO
}
catch (DirectoryNotFoundException ex)
{
_logger.LogError<PhysicalFileSystem>(ex, "Directory not found for '{Path}'", fullPath);
_logger.LogError(ex, "Directory not found for '{Path}'", fullPath);
}
}
@@ -203,11 +203,11 @@ namespace Umbraco.Core.IO
}
catch (UnauthorizedAccessException ex)
{
_logger.LogError<PhysicalFileSystem>(ex, "Not authorized to get directories for '{Path}'", fullPath);
_logger.LogError(ex, "Not authorized to get directories for '{Path}'", fullPath);
}
catch (DirectoryNotFoundException ex)
{
_logger.LogError<PhysicalFileSystem>(ex, "Directory not found for '{FullPath}'", fullPath);
_logger.LogError(ex, "Directory not found for '{FullPath}'", fullPath);
}
return Enumerable.Empty<string>();
@@ -240,7 +240,7 @@ namespace Umbraco.Core.IO
}
catch (FileNotFoundException ex)
{
_logger.LogError<PhysicalFileSystem>(ex.InnerException, "DeleteFile failed with FileNotFoundException for '{Path}'", fullPath);
_logger.LogError(ex.InnerException, "DeleteFile failed with FileNotFoundException for '{Path}'", fullPath);
}
}

View File

@@ -16,46 +16,6 @@ namespace Umbraco.Core.Logging
public static bool IsEnabled<T>(this ILogger logger, LogLevel level)
=> logger.IsEnabled(typeof(T), level);
/// <summary>
/// Logs an error message with an exception.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="message">A message.</param>
/// <param name="exception">An exception.</param>
public static void LogError<T>(this ILogger logger, Exception exception, string message)
=> logger.LogError(exception, message);
/// <summary>
/// Logs an error message with an exception.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="exception">An exception.</param>
/// <param name="messageTemplate">A message template.</param>
/// <param name="propertyValues">Property values.</param>
public static void LogError<T>(this ILogger logger, Exception exception, string messageTemplate, params object[] propertyValues)
=> logger.LogError(exception, messageTemplate, propertyValues);
/// <summary>
/// Logs an error message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="message">A message.</param>
public static void LogError<T>(this ILogger logger, string message)
=> logger.LogError(message);
/// <summary>
/// Logs an error message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="messageTemplate">A message template.</param>
/// <param name="propertyValues">Property values.</param>
public static void LogError<T>(this ILogger logger, string messageTemplate, params object[] propertyValues)
=> logger.LogError(messageTemplate, propertyValues);
/// <summary>
/// Logs a warning message.
/// </summary>
@@ -96,25 +56,6 @@ namespace Umbraco.Core.Logging
public static void LogWarning<T>(this ILogger logger, Exception exception, string messageTemplate, params object[] propertyValues)
=> logger.LogWarning(exception, messageTemplate, propertyValues);
/// <summary>
/// Logs an information message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="message">A message.</param>
public static void LogInformation<T>(this ILogger logger, string message)
=> logger.LogInformation(message);
/// <summary>
/// Logs a information message.
/// </summary>
/// <typeparam name="T">The reporting type</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="messageTemplate">A message template.</param>
/// <param name="propertyValues">Property values.</param>
public static void LogInformation<T>(this ILogger logger, string messageTemplate, params object[] propertyValues)
=> logger.LogInformation(messageTemplate, propertyValues);
/// <summary>
/// Logs a debugging message.
/// </summary>
@@ -143,26 +84,5 @@ namespace Umbraco.Core.Logging
/// <param name="propertyValues">Property values.</param>
public static void Verbose<T>(this ILogger logger, string messageTemplate, params object[] propertyValues)
=> logger.LogTrace(messageTemplate, propertyValues);
/// <summary>
/// Logs a fatal message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="exception">An exception.</param>
/// <param name="message">A message.</param>
public static void Fatal<T>(this ILogger logger, Exception exception, string message)
=> logger.LogCritical(exception, message);
/// <summary>
/// Logs a fatal message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="exception">An exception.</param>
/// <param name="messageTemplate">A message template.</param>
/// <param name="propertyValues">Property values.</param>
public static void Fatal<T>(this ILogger logger, Exception exception, string messageTemplate, params object[] propertyValues)
=> logger.LogCritical(exception, messageTemplate, propertyValues);
}
}

View File

@@ -38,7 +38,7 @@ namespace Umbraco.Web.Models.Mapping
var editor = _propertyEditors[property.PropertyType.PropertyEditorAlias];
if (editor == null)
{
_logger.LogError<ContentPropertyBasicMapper<TDestination>>(
_logger.LogError(
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);

View File

@@ -34,7 +34,7 @@ namespace Umbraco.Core.Packaging
catch (Exception ex)
{
e.Add($"{ipa.Alias()} - {ex.Message}");
_logger.LogError<PackageActionRunner>(ex, "Error loading package action '{PackageActionAlias}' for package {PackageName}", ipa.Alias(), packageName);
_logger.LogError(ex, "Error loading package action '{PackageActionAlias}' for package {PackageName}", ipa.Alias(), packageName);
}
}
@@ -56,7 +56,7 @@ namespace Umbraco.Core.Packaging
catch (Exception ex)
{
e.Add($"{ipa.Alias()} - {ex.Message}");
_logger.LogError<PackageActionRunner>(ex, "Error undoing package action '{PackageActionAlias}' for package {PackageName}", ipa.Alias(), packageName);
_logger.LogError(ex, "Error undoing package action '{PackageActionAlias}' for package {PackageName}", ipa.Alias(), packageName);
}
}
errors = e;

View File

@@ -123,7 +123,7 @@ namespace Umbraco.Web.Routing
}
catch (Exception ex)
{
logger.LogError<UrlProvider>(ex, "GetUrl exception.");
logger.LogError(ex, "GetUrl exception.");
url = "#ex";
}

View File

@@ -121,7 +121,7 @@ namespace Umbraco.Core.Runtime
}
catch (Exception e)
{
_logger.LogError<MainDom>(e, "Error while running callback");
_logger.LogError(e, "Error while running callback");
continue;
}
}

View File

@@ -225,7 +225,7 @@ namespace Umbraco.Web.Compose
}
catch (Exception e)
{
_logger.LogError<InstructionProcessTask>(e, "Failed (will repeat).");
_logger.LogError(e, "Failed (will repeat).");
}
return true; // repeat
}
@@ -268,7 +268,7 @@ namespace Umbraco.Web.Compose
}
catch (Exception ex)
{
_logger.LogError<DatabaseServerRegistrarAndMessengerComponent>(ex, "Failed to update server record in database.");
_logger.LogError(ex, "Failed to update server record in database.");
return false; // probably stop if we have an error
}
}

View File

@@ -55,7 +55,7 @@ namespace Umbraco.Examine
}
catch (Exception ex)
{
_logger.LogError<MediaValueSetBuilder>(ex, $"Could not Deserialize ImageCropperValue for item with key {m.Key} ");
_logger.LogError(ex, $"Could not Deserialize ImageCropperValue for item with key {m.Key} ");
}
if (cropper != null)

View File

@@ -27,7 +27,7 @@ namespace Umbraco.Web.HealthCheck
}
catch (Exception ex)
{
Logger.LogError<HealthCheckResults>(ex, "Error running scheduled health check: {HealthCheckName}", t.Name);
Logger.LogError(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<HealthCheckStatus>
{

View File

@@ -103,7 +103,7 @@ namespace Umbraco.Web.Install
}
catch (Exception ex)
{
_logger.LogError<InstallHelper>(ex, "An error occurred in InstallStatus trying to check upgrades");
_logger.LogError(ex, "An error occurred in InstallStatus trying to check upgrades");
}
}
@@ -154,7 +154,7 @@ namespace Umbraco.Web.Install
}
catch (AggregateException ex)
{
_logger.LogError<InstallHelper>(ex, "Could not download list of available starter kits");
_logger.LogError(ex, "Could not download list of available starter kits");
}
return packages;

View File

@@ -119,7 +119,7 @@ namespace Umbraco.Web.Install.InstallSteps
}
catch (Exception ex)
{
_logger.LogError<DatabaseConfigureStep>(ex, "An error occurred, reconfiguring...");
_logger.LogError(ex, "An error occurred, reconfiguring...");
//something went wrong, could not connect so probably need to reconfigure
return true;
}

View File

@@ -128,7 +128,7 @@ namespace Umbraco.Core.Logging.Viewer
{
// As we are reading/streaming one line at a time in the JSON file
// Thus we can not report the line number, as it will always be 1
_logger.LogError<SerilogJsonLogViewer>(ex, "Unable to parse a line in the JSON log file");
_logger.LogError(ex, "Unable to parse a line in the JSON log file");
evt = null;
return true;

View File

@@ -115,7 +115,7 @@ namespace Umbraco.Core.Manifest
}
catch (Exception e)
{
_logger.LogError<ManifestParser>(e, "Failed to parse manifest at '{Path}', ignoring.", path);
_logger.LogError(e, "Failed to parse manifest at '{Path}', ignoring.", path);
}
}

View File

@@ -449,7 +449,7 @@ namespace Umbraco.Core.Migrations.Install
private Result HandleInstallException(Exception ex)
{
_logger.LogError<DatabaseBuilder>(ex, "Database configuration failed");
_logger.LogError(ex, "Database configuration failed");
if (_databaseSchemaValidationResult != null)
{

View File

@@ -111,7 +111,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.LogError<DatabaseSchemaCreator>(ex, "Could not drop table {TableName}", tableName);
_logger.LogError(ex, "Could not drop table {TableName}", tableName);
}
}
}

View File

@@ -51,7 +51,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
}
catch (Exception ex)
{
Logger.LogError<DropDownPropertyEditorsMigration>(
Logger.LogError(
ex, "Invalid configuration: \"{Configuration}\", cannot convert editor.",
dataType.Configuration);

View File

@@ -40,7 +40,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
}
catch (Exception ex)
{
Logger.LogError<DropDownPropertyEditorsMigration>(
Logger.LogError(
ex,
"Invalid property editor configuration detected: \"{Configuration}\", cannot convert editor, values will be cleared",
dataType.Configuration);

View File

@@ -55,7 +55,7 @@ namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
}
catch (Exception ex)
{
Logger.LogError<DropDownPropertyEditorsMigration>(
Logger.LogError(
ex, "Invalid configuration: \"{Configuration}\", cannot convert editor.",
dataType.Configuration);

View File

@@ -539,7 +539,7 @@ namespace Umbraco.Core.Packaging
var tryCreateFolder = _contentTypeService.CreateContainer(-1, rootFolder);
if (tryCreateFolder == false)
{
_logger.LogError<PackagingService>(tryCreateFolder.Exception, "Could not create folder: {FolderName}", rootFolder);
_logger.LogError(tryCreateFolder.Exception, "Could not create folder: {FolderName}", rootFolder);
throw tryCreateFolder.Exception;
}
var rootFolderId = tryCreateFolder.Result.Entity.Id;
@@ -573,7 +573,7 @@ namespace Umbraco.Core.Packaging
var tryCreateFolder = _contentTypeService.CreateContainer(current.Id, folderName);
if (tryCreateFolder == false)
{
_logger.LogError<PackagingService>(tryCreateFolder.Exception, "Could not create folder: {FolderName}", folderName);
_logger.LogError(tryCreateFolder.Exception, "Could not create folder: {FolderName}", folderName);
throw tryCreateFolder.Exception;
}
return _contentTypeService.GetContainer(tryCreateFolder.Result.Entity.Id);
@@ -952,7 +952,7 @@ namespace Umbraco.Core.Packaging
var tryCreateFolder = _dataTypeService.CreateContainer(-1, rootFolder);
if (tryCreateFolder == false)
{
_logger.LogError<PackagingService>(tryCreateFolder.Exception, "Could not create folder: {FolderName}", rootFolder);
_logger.LogError(tryCreateFolder.Exception, "Could not create folder: {FolderName}", rootFolder);
throw tryCreateFolder.Exception;
}
current = _dataTypeService.GetContainer(tryCreateFolder.Result.Entity.Id);
@@ -985,7 +985,7 @@ namespace Umbraco.Core.Packaging
var tryCreateFolder = _dataTypeService.CreateContainer(current.Id, folderName);
if (tryCreateFolder == false)
{
_logger.LogError<PackagingService>(tryCreateFolder.Exception, "Could not create folder: {FolderName}", folderName);
_logger.LogError(tryCreateFolder.Exception, "Could not create folder: {FolderName}", folderName);
throw tryCreateFolder.Exception;
}
return _dataTypeService.GetContainer(tryCreateFolder.Result.Entity.Id);

View File

@@ -226,7 +226,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
if (string.IsNullOrWhiteSpace(entity.Alias))
{
var ex = new Exception($"ContentType '{entity.Name}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.");
Logger.LogError<ContentTypeRepository>("ContentType '{EntityName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.", entity.Name);
Logger.LogError("ContentType '{EntityName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.", entity.Name);
throw ex;
}

View File

@@ -1216,7 +1216,7 @@ AND umbracoNode.id <> @id",
{
var ex = new InvalidOperationException($"Property Type '{pt.Name}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.");
Logger.LogError<ContentTypeRepositoryBase<TEntity>>("Property Type '{PropertyTypeName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.",
Logger.LogError("Property Type '{PropertyTypeName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.",
pt.Name);
throw ex;
@@ -1229,7 +1229,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.LogError<ContentTypeRepositoryBase<TEntity>>("{EntityTypeName} '{EntityName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.",
Logger.LogError("{EntityTypeName} '{EntityName}' cannot have an empty Alias. This is most likely due to invalid characters stripped from the Alias.",
typeof(TEntity).Name,
entity.Name);

View File

@@ -161,7 +161,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
}
catch (Exception e)
{
logger.LogError<UmbracoDatabaseFactory>(e, "Failed to detected SqlServer version.");
logger.LogError(e, "Failed to detected SqlServer version.");
version = new ServerVersionInfo(); // all unknown
}
}

View File

@@ -226,7 +226,7 @@ namespace Umbraco.Core.Persistence
protected override void OnException(Exception ex)
{
_logger.LogError<UmbracoDatabase>(ex, "Exception ({InstanceId}).", InstanceId);
_logger.LogError(ex, "Exception ({InstanceId}).", InstanceId);
_logger.Debug<UmbracoDatabase>("At:\r\n{StackTrace}", Environment.StackTrace);
if (EnableSqlTrace == false)
_logger.Debug<UmbracoDatabase>("Sql:\r\n{Sql}", CommandToString(LastSQL, LastArgs));

View File

@@ -103,7 +103,7 @@ namespace Umbraco.Web.PropertyEditors
catch (Exception ex)
{
if (writeLog)
Logger.LogError<ImageCropperPropertyEditor>(ex, "Could not parse image cropper value '{Json}'", value);
Logger.LogError(ex, "Could not parse image cropper value '{Json}'", value);
return null;
}
}

View File

@@ -122,7 +122,7 @@ namespace Umbraco.Web.PropertyEditors
}
catch (Exception ex)
{
_logger.LogError<MultiUrlPickerValueEditor>("Error getting links", ex);
_logger.LogError("Error getting links", ex);
}
return base.ToEditor(property, culture, segment);
@@ -157,7 +157,7 @@ namespace Umbraco.Web.PropertyEditors
}
catch (Exception ex)
{
_logger.LogError<MultiUrlPickerValueEditor>("Error saving links", ex);
_logger.LogError("Error saving links", ex);
}
return base.FromEditor(editorValue, currentValue);

View File

@@ -92,7 +92,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
}
catch (Exception ex)
{
Current.Logger.LogError<GridValueConverter>(ex, "Could not parse the string '{JsonString}' to a json object", sourceString);
Current.Logger.LogError(ex, "Could not parse the string '{JsonString}' to a json object", sourceString);
}
}

View File

@@ -44,7 +44,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
catch (Exception ex)
{
// cannot deserialize, assume it may be a raw image url
Current.Logger.LogError<ImageCropperValueConverter>(ex, "Could not deserialize string '{JsonString}' into an image cropper value.", sourceString);
Current.Logger.LogError(ex, "Could not deserialize string '{JsonString}' into an image cropper value.", sourceString);
value = new ImageCropperValue { Src = sourceString };
}

View File

@@ -58,7 +58,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
}
catch (Exception ex)
{
Current.Logger.LogError<JsonValueConverter>(ex, "Could not parse the string '{JsonString}' to a json object", sourceString);
Current.Logger.LogError(ex, "Could not parse the string '{JsonString}' to a json object", sourceString);
}
}

View File

@@ -107,7 +107,7 @@ namespace Umbraco.Web.Routing
}
catch (Exception ex)
{
Current.Logger.LogError<NotFoundHandlerHelper>(ex, "Could not parse xpath expression: {ContentXPath}", errorPage.ContentXPath);
Current.Logger.LogError(ex, "Could not parse xpath expression: {ContentXPath}", errorPage.ContentXPath);
return null;
}
}

View File

@@ -34,7 +34,7 @@ namespace Umbraco.Core.Runtime
private readonly IConnectionStrings _connectionStrings;
public CoreRuntime(
Configs configs,
Configs configs,
IUmbracoVersion umbracoVersion,
IIOHelper ioHelper,
ILogger logger,
@@ -59,7 +59,7 @@ namespace Umbraco.Core.Runtime
_loggerFactory = loggerFactory;
_umbracoBootPermissionChecker = umbracoBootPermissionChecker;
Logger = logger;
MainDom = mainDom;
TypeFinder = typeFinder;
@@ -275,7 +275,7 @@ namespace Umbraco.Core.Runtime
var msg = "Unhandled exception in AppDomain";
if (isTerminating) msg += " (terminating)";
msg += ".";
Logger.LogError<CoreRuntime>(exception, msg);
Logger.LogError(exception, msg);
};
}

View File

@@ -52,7 +52,7 @@ namespace Umbraco.Core.Runtime
}
catch (TimeoutException ex)
{
_logger.LogError<MainDomSemaphoreLock>(ex.Message);
_logger.LogError(ex.Message);
return Task.FromResult(false);
}
finally

View File

@@ -78,7 +78,7 @@ namespace Umbraco.Core.Runtime
{
if (IsLockTimeoutException(ex))
{
_logger.LogError<SqlMainDomLock>(ex, "Sql timeout occurred, could not acquire MainDom.");
_logger.LogError(ex, "Sql timeout occurred, could not acquire MainDom.");
_errorDuringAcquiring = true;
return false;
}
@@ -103,7 +103,7 @@ namespace Umbraco.Core.Runtime
catch (Exception ex)
{
// unexpected
_logger.LogError<SqlMainDomLock>(ex, "Unexpected error, cannot acquire MainDom");
_logger.LogError(ex, "Unexpected error, cannot acquire MainDom");
_errorDuringAcquiring = true;
return false;
}
@@ -186,7 +186,7 @@ namespace Umbraco.Core.Runtime
}
catch (Exception ex)
{
_logger.LogError<SqlMainDomLock>(ex, "Unexpected error during listening.");
_logger.LogError(ex, "Unexpected error during listening.");
// We need to keep on listening unless we've been notified by our own AppDomain to shutdown since
// we don't want to shutdown resources controlled by MainDom inadvertently. We'll just keep listening otherwise.
@@ -277,12 +277,12 @@ namespace Umbraco.Core.Runtime
{
if (IsLockTimeoutException(ex as SqlException))
{
_logger.LogError<SqlMainDomLock>(ex, "Sql timeout occurred, waiting for existing MainDom is canceled.");
_logger.LogError(ex, "Sql timeout occurred, waiting for existing MainDom is canceled.");
_errorDuringAcquiring = true;
return false;
}
// unexpected
_logger.LogError<SqlMainDomLock>(ex, "Unexpected error, waiting for existing MainDom is canceled.");
_logger.LogError(ex, "Unexpected error, waiting for existing MainDom is canceled.");
_errorDuringAcquiring = true;
return false;
}
@@ -321,11 +321,11 @@ namespace Umbraco.Core.Runtime
if (IsLockTimeoutException(ex as SqlException))
{
// something is wrong, we cannot acquire, not much we can do
_logger.LogError<SqlMainDomLock>(ex, "Sql timeout occurred, could not forcibly acquire MainDom.");
_logger.LogError(ex, "Sql timeout occurred, could not forcibly acquire MainDom.");
_errorDuringAcquiring = true;
return false;
}
_logger.LogError<SqlMainDomLock>(ex, "Unexpected error, could not forcibly acquire MainDom.");
_logger.LogError(ex, "Unexpected error, could not forcibly acquire MainDom.");
_errorDuringAcquiring = true;
return false;
}
@@ -409,7 +409,7 @@ namespace Umbraco.Core.Runtime
}
catch (Exception ex)
{
_logger.LogError<SqlMainDomLock>(ex, "Unexpected error during dipsose.");
_logger.LogError(ex, "Unexpected error during dipsose.");
}
finally
{

View File

@@ -414,7 +414,7 @@ namespace Umbraco.Web.Scheduling
}
catch (Exception ex)
{
_logger.LogError<BackgroundTaskRunner>(ex, "{LogPrefix} Task runner exception", _logPrefix);
_logger.LogError(ex, "{LogPrefix} Task runner exception", _logPrefix);
}
}
}
@@ -573,7 +573,7 @@ namespace Umbraco.Web.Scheduling
catch (Exception ex)
{
_logger.LogError<BackgroundTaskRunner>(ex, "{LogPrefix} Task has failed", _logPrefix);
_logger.LogError(ex, "{LogPrefix} Task has failed", _logPrefix);
}
}
@@ -617,7 +617,7 @@ namespace Umbraco.Web.Scheduling
}
catch (Exception ex)
{
_logger.LogError<BackgroundTaskRunner>(ex, "{LogPrefix} {Name} exception occurred", _logPrefix, name);
_logger.LogError(ex, "{LogPrefix} {Name} exception occurred", _logPrefix, name);
}
}

View File

@@ -97,7 +97,7 @@ namespace Umbraco.Web.Search
}
catch (Exception ex)
{
_logger.LogError<RebuildOnStartupTask>(ex, "Failed to rebuild empty indexes.");
_logger.LogError(ex, "Failed to rebuild empty indexes.");
}
}

View File

@@ -1417,7 +1417,7 @@ namespace Umbraco.Core.Services.Implement
var result = CommitDocumentChangesInternal(scope, d, saveEventArgs, allLangs.Value, d.WriterId);
if (result.Success == false)
Logger.LogError<ContentService>(null, "Failed to publish document id={DocumentId}, reason={Reason}.", d.Id, result.Result);
Logger.LogError(null, "Failed to publish document id={DocumentId}, reason={Reason}.", d.Id, result.Result);
results.Add(result);
}
@@ -1427,7 +1427,7 @@ namespace Umbraco.Core.Services.Implement
d.ContentSchedule.Clear(ContentScheduleAction.Expire, date);
var result = Unpublish(d, userId: d.WriterId);
if (result.Success == false)
Logger.LogError<ContentService>(null, "Failed to unpublish document id={DocumentId}, reason={Reason}.", d.Id, result.Result);
Logger.LogError(null, "Failed to unpublish document id={DocumentId}, reason={Reason}.", d.Id, result.Result);
results.Add(result);
}
}
@@ -1498,7 +1498,7 @@ namespace Umbraco.Core.Services.Implement
result = CommitDocumentChangesInternal(scope, d, saveEventArgs, allLangs.Value, d.WriterId);
if (result.Success == false)
Logger.LogError<ContentService>(null, "Failed to publish document id={DocumentId}, reason={Reason}.", d.Id, result.Result);
Logger.LogError(null, "Failed to publish document id={DocumentId}, reason={Reason}.", d.Id, result.Result);
results.Add(result);
}
@@ -1512,7 +1512,7 @@ namespace Umbraco.Core.Services.Implement
: SaveAndPublish(d, userId: d.WriterId);
if (result.Success == false)
Logger.LogError<ContentService>(null, "Failed to publish document id={DocumentId}, reason={Reason}.", d.Id, result.Result);
Logger.LogError(null, "Failed to publish document id={DocumentId}, reason={Reason}.", d.Id, result.Result);
results.Add(result);
}
@@ -3164,7 +3164,7 @@ namespace Umbraco.Core.Services.Implement
if (rollbackSaveResult.Success == false)
{
//Log the error/warning
Logger.LogError<ContentService>("User '{UserId}' was unable to rollback content '{ContentId}' to version '{VersionId}'", userId, id, versionId);
Logger.LogError("User '{UserId}' was unable to rollback content '{ContentId}' to version '{VersionId}'", userId, id, versionId);
}
else
{

View File

@@ -206,7 +206,7 @@ namespace Umbraco.Core.Services.Implement
}
catch (Exception ex)
{
_logger.LogError<LocalizedTextServiceFileSources>(ex, "Could not load file into XML {File}", supplementaryFile.File.FullName);
_logger.LogError(ex, "Could not load file into XML {File}", supplementaryFile.File.FullName);
continue;
}

View File

@@ -523,7 +523,7 @@ namespace Umbraco.Core.Services.Implement
}
catch (Exception ex)
{
_logger.LogError<NotificationService>(ex, "An error occurred sending notification");
_logger.LogError(ex, "An error occurred sending notification");
}
finally
{

View File

@@ -361,7 +361,7 @@ namespace Umbraco.Core.Sync
}
catch (JsonException ex)
{
Logger.LogError<DatabaseServerMessenger>(ex, "Failed to deserialize instructions ({DtoId}: '{DtoInstructions}').",
Logger.LogError(ex, "Failed to deserialize instructions ({DtoId}: '{DtoInstructions}').",
dto.Id,
dto.Instructions);
@@ -419,7 +419,7 @@ namespace Umbraco.Core.Sync
//}
catch (Exception ex)
{
Logger.LogError<DatabaseServerMessenger>(
Logger.LogError(
ex,
"DISTRIBUTED CACHE IS NOT UPDATED. Failed to execute instructions ({DtoId}: '{DtoInstructions}'). Instruction is being skipped/ignored",
dto.Id,

View File

@@ -97,7 +97,7 @@ namespace Umbraco.ModelsBuilder.Embedded
catch (Exception e)
{
_mbErrors.Report("Failed to build Live models.", e);
_logger.LogError<LiveModelsProvider>("Failed to generate models.", e);
_logger.LogError("Failed to generate models.", e);
}
finally
{

View File

@@ -41,7 +41,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
}
catch (Exception ex)
{
Current.Logger.LogError<PreviewContent>(ex, "Could not load preview set {PreviewSet} for user {UserId}.", _previewSet, _userId);
Current.Logger.LogError(ex, "Could not load preview set {PreviewSet} for user {UserId}.", _previewSet, _userId);
ClearPreviewSet();
@@ -147,7 +147,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
}
catch (Exception ex)
{
Current.Logger.LogError<PreviewContent>(ex, "Couldn't delete preview set {FileName} for user {UserId}", file.Name, userId);
Current.Logger.LogError(ex, "Couldn't delete preview set {FileName} for user {UserId}", file.Name, userId);
}
}

View File

@@ -134,13 +134,13 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
//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.LogError<PublishedMediaCache>(ex, "Could not load data from Examine index for media");
Current.Logger.LogError(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.LogError<PublishedMediaCache>(ex, "Could not load data from Examine index for media, the app domain is most likely in a shutdown state");
Current.Logger.LogError(ex, "Could not load data from Examine index for media, the app domain is most likely in a shutdown state");
}
else throw;
}
@@ -302,13 +302,13 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
//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.LogError<PublishedMediaCache>(ex, "Could not load data from Examine index for media");
Current.Logger.LogError(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.LogError<PublishedMediaCache>(ex, "Could not load data from Examine index for media, the app domain is most likely in a shutdown state");
Current.Logger.LogError(ex, "Could not load data from Examine index for media, the app domain is most likely in a shutdown state");
}
else throw;
}

View File

@@ -415,7 +415,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
}
catch (Exception ex)
{
Current.Logger.LogError<ContentTypeService>(ex, "Failed to build a DTD for the Xml cache.");
Current.Logger.LogError(ex, "Failed to build a DTD for the Xml cache.");
}
dtd.AppendLine("]>");
@@ -705,7 +705,7 @@ AND (umbracoNode.id=@id)";
// if something goes wrong remove the file
DeleteXmlFile();
Current.Logger.LogError<XmlStore>(ex, "Failed to save Xml to file '{FileName}'.", _xmlFileName);
Current.Logger.LogError(ex, "Failed to save Xml to file '{FileName}'.", _xmlFileName);
}
}
@@ -745,7 +745,7 @@ AND (umbracoNode.id=@id)";
// if something goes wrong remove the file
DeleteXmlFile();
Current.Logger.LogError<XmlStore>(ex, "Failed to save Xml to file '{FileName}'.", _xmlFileName);
Current.Logger.LogError(ex, "Failed to save Xml to file '{FileName}'.", _xmlFileName);
}
}
@@ -802,7 +802,7 @@ AND (umbracoNode.id=@id)";
}
catch (Exception ex)
{
Current.Logger.LogError<XmlStore>(ex, "Failed to load Xml from file '{FileName}'.", _xmlFileName);
Current.Logger.LogError(ex, "Failed to load Xml from file '{FileName}'.", _xmlFileName);
try
{
DeleteXmlFile();

View File

@@ -344,7 +344,7 @@ namespace Umbraco.Tests.TestHelpers
}
catch (Exception ex)
{
Logger.LogError<TestWithDatabaseBase>(ex, "Could not remove the old database file");
Logger.LogError(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);

View File

@@ -1628,7 +1628,7 @@ namespace Umbraco.Web.Editors
}
catch (Exception ex)
{
Logger.LogError<ContentController>(ex, "Could not update content sort order");
Logger.LogError(ex, "Could not update content sort order");
throw;
}
}

View File

@@ -632,7 +632,7 @@ namespace Umbraco.Web.BackOffice.Controllers
}
catch (Exception ex)
{
_logger.LogError<ContentTypeController>(ex, "Error cleaning up temporary udt file in App_Data: {File}", filePath);
_logger.LogError(ex, "Error cleaning up temporary udt file in App_Data: {File}", filePath);
}
return Ok();

View File

@@ -98,7 +98,7 @@ namespace Umbraco.Web.BackOffice.Controllers
}
catch (HttpRequestException ex)
{
_logger.LogError<DashboardController>(ex.InnerException ?? ex, "Error getting dashboard content from {Url}", url);
_logger.LogError(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
_appCaches.RuntimeCache.InsertCacheItem<JObject>(key, () => result, new TimeSpan(0, 5, 0));
@@ -136,7 +136,7 @@ namespace Umbraco.Web.BackOffice.Controllers
}
catch (HttpRequestException ex)
{
_logger.LogError<DashboardController>(ex.InnerException ?? ex, "Error getting dashboard CSS from {Url}", url);
_logger.LogError(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
_appCaches.RuntimeCache.InsertCacheItem<string>(key, () => result, new TimeSpan(0, 5, 0));
@@ -199,7 +199,7 @@ namespace Umbraco.Web.BackOffice.Controllers
}
catch (HttpRequestException ex)
{
_logger.LogError<DashboardController>(ex.InnerException ?? ex, "Error getting remote dashboard data from {UrlPrefix}{Url}", urlPrefix, url);
_logger.LogError(ex.InnerException ?? ex, "Error getting remote dashboard data from {UrlPrefix}{Url}", urlPrefix, url);
//it's still string.Empty - we return it like this to avoid error codes which triggers UI warnings
_appCaches.RuntimeCache.InsertCacheItem<string>(key, () => result, new TimeSpan(0, 5, 0));

View File

@@ -162,7 +162,7 @@ namespace Umbraco.Web.BackOffice.Controllers
{
//ensure it's not listening
index.IndexOperationComplete -= Indexer_IndexOperationComplete;
_logger.LogError<ExamineManagementController>(ex, "An error occurred rebuilding index");
_logger.LogError(ex, "An error occurred rebuilding index");
var response = new ConflictObjectResult("The index could not be rebuilt at this time, most likely there is another thread currently writing to the index. Error: {ex}");
HttpContext.SetReasonPhrase("Could Not Rebuild");

View File

@@ -102,7 +102,7 @@ namespace Umbraco.Web.BackOffice.Controllers
catch (Exception exception)
{
const string errorMessage = "Error creating macro";
_logger.LogError<MacrosController>(exception, errorMessage);
_logger.LogError(exception, errorMessage);
throw HttpResponseException.CreateNotificationValidationErrorResponse(errorMessage);
}
}
@@ -226,7 +226,7 @@ namespace Umbraco.Web.BackOffice.Controllers
catch (Exception exception)
{
const string errorMessage = "Error creating macro";
_logger.LogError<MacrosController>(exception, errorMessage);
_logger.LogError(exception, errorMessage);
throw HttpResponseException.CreateNotificationValidationErrorResponse(errorMessage);
}
}

View File

@@ -629,7 +629,7 @@ namespace Umbraco.Web.BackOffice.Controllers
}
catch (Exception ex)
{
Logger.LogError<MediaController>(ex, "Could not update media sort order");
Logger.LogError(ex, "Could not update media sort order");
throw;
}
}

View File

@@ -99,7 +99,7 @@ namespace Umbraco.Web.BackOffice.Controllers
}
catch (Exception ex)
{
_logger.LogError<PackageInstallController>(ex, "Failed to uninstall.");
_logger.LogError(ex, "Failed to uninstall.");
throw;
}

View File

@@ -75,7 +75,7 @@ namespace Umbraco.Web.WebApi.Filters
}
catch (Exception ex)
{
_logger.LogError<FileUploadCleanupFilterAttribute>(ex,
_logger.LogError(ex,
"Could not delete temp file {FileName}", f.TempFilePath);
}
}
@@ -129,7 +129,7 @@ namespace Umbraco.Web.WebApi.Filters
}
catch (Exception ex)
{
_logger.LogError<FileUploadCleanupFilterAttribute>(ex,
_logger.LogError(ex,
"Could not delete temp file {FileName}", f.TempFilePath);
}

View File

@@ -104,7 +104,7 @@ namespace Umbraco.Web.BackOffice.Filters
}
catch (AntiforgeryValidationException ex)
{
_logger.LogError<ValidateAntiForgeryTokenAttribute>(ex, "Could not validate XSRF token");
_logger.LogError(ex, "Could not validate XSRF token");
return false;
}
}

View File

@@ -71,7 +71,7 @@ namespace Umbraco.Web.BackOffice.Controllers
}
catch (Exception ex)
{
_logger.LogError<HealthCheckController>(ex, "Exception in health check: {HealthCheckName}", check.Name);
_logger.LogError(ex, "Exception in health check: {HealthCheckName}", check.Name);
throw;
}
}

View File

@@ -63,7 +63,7 @@ namespace Umbraco.Web.BackOffice.PropertyEditors
}
catch(Exception ex)
{
_logger.LogError<RteEmbedController>(ex, "Error embedding url {Url} - width: {Width} height: {Height}", url, width, height);
_logger.LogError(ex, "Error embedding url {Url} - width: {Width} height: {Height}", url, width, height);
result.OEmbedStatus = OEmbedStatus.Error;
}

View File

@@ -45,7 +45,7 @@ namespace Umbraco.Web.Common.Install
}
catch (Exception ex)
{
logger.LogError<InstallAuthorizeAttribute>(ex, "An error occurred determining authorization");
logger.LogError(ex, "An error occurred determining authorization");
return false;
}
}

View File

@@ -53,7 +53,7 @@ namespace Umbraco.Web.Common.Middleware
try
{
if (umbracoContextReference.UmbracoContext.IsFrontEndUmbracoRequest)
{
{
LogHttpRequest.TryGetCurrentHttpRequestId(out var httpRequestId, _requestCache);
_logger.Verbose<UmbracoRequestMiddleware>("Begin request [{HttpRequestId}]: {RequestUrl}", httpRequestId, requestUri);
}
@@ -65,7 +65,7 @@ namespace Umbraco.Web.Common.Middleware
catch (Exception ex)
{
// try catch so we don't kill everything in all requests
_logger.LogError<UmbracoRequestMiddleware>(ex.Message);
_logger.LogError(ex.Message);
}
finally
{
@@ -128,7 +128,7 @@ namespace Umbraco.Web.Common.Middleware
}
catch (Exception ex)
{
logger.LogError<UmbracoRequestMiddleware>("Could not dispose item with key " + k, ex);
logger.LogError("Could not dispose item with key " + k, ex);
}
try
{
@@ -136,7 +136,7 @@ namespace Umbraco.Web.Common.Middleware
}
catch (Exception ex)
{
logger.LogError<UmbracoRequestMiddleware>("Could not dispose item key " + k, ex);
logger.LogError("Could not dispose item key " + k, ex);
}
}
}

View File

@@ -36,12 +36,12 @@ namespace Umbraco.Web
public void Error(string msg, Exception ex)
{
_logger.LogError<CdfLogger>(ex, msg);
_logger.LogError(ex, msg);
}
public void Fatal(string msg, Exception ex)
{
_logger.LogError<CdfLogger>(ex, msg);
_logger.LogError(ex, msg);
}
}
}

View File

@@ -28,7 +28,7 @@ namespace Umbraco.Web
{
// Using LogHelper since the ImageProcessor logger expects a parameterless constructor.
var message = $"{callerName} {lineNumber} : {text}";
Current.Logger.LogError<T>(new ImageProcessingException(message).Message);
Current.Logger.LogError(new ImageProcessingException(message).Message);
}
/// <summary>

View File

@@ -119,7 +119,7 @@ namespace Umbraco.Web.Mvc
}
catch (Exception ex)
{
Logger.LogError<AdminTokenAuthorizeAttribute>(ex, "Failed to format passed in token value");
Logger.LogError(ex, "Failed to format passed in token value");
return false;
}
}

View File

@@ -257,7 +257,7 @@ namespace Umbraco.Web.Security
if ((PasswordFormat == MembershipPasswordFormat.Hashed) && EnablePasswordRetrieval)
{
var ex = new ProviderException("Provider can not retrieve a hashed password");
Current.Logger.LogError<MembershipProviderBase>(ex, "Cannot specify a Hashed password format with the enabledPasswordRetrieval option set to true");
Current.Logger.LogError(ex, "Cannot specify a Hashed password format with the enabledPasswordRetrieval option set to true");
throw ex;
}

View File

@@ -294,7 +294,7 @@ namespace Umbraco.Web
// ignore HTTP errors
if (exception.GetType() == typeof(HttpException)) return;
Current.Logger.LogError<UmbracoApplicationBase>(exception, "An unhandled exception occurred");
Current.Logger.LogError(exception, "An unhandled exception occurred");
}
// called by ASP.NET (auto event wireup) at any phase in the application life cycle
@@ -317,7 +317,7 @@ namespace Umbraco.Web
}
catch (Exception ex)
{
Current.Logger.LogError<UmbracoApplicationBase>(ex, "Error in {Name} handler.", name);
Current.Logger.LogError(ex, "Error in {Name} handler.", name);
throw;
}
}

View File

@@ -57,7 +57,7 @@ namespace Umbraco.Web.WebApi.Filters
}
catch (System.Exception ex)
{
Current.Logger.LogError<FileUploadCleanupFilterAttribute>(ex, "Could not delete temp file {FileName}", f.TempFilePath);
Current.Logger.LogError(ex, "Could not delete temp file {FileName}", f.TempFilePath);
}
}
}
@@ -89,7 +89,7 @@ namespace Umbraco.Web.WebApi.Filters
}
catch (System.Exception ex)
{
Current.Logger.LogError<FileUploadCleanupFilterAttribute>(ex, "Could not acquire actionExecutedContext.Response.Content");
Current.Logger.LogError(ex, "Could not acquire actionExecutedContext.Response.Content");
return;
}
@@ -119,7 +119,7 @@ namespace Umbraco.Web.WebApi.Filters
}
catch (System.Exception ex)
{
Current.Logger.LogError<FileUploadCleanupFilterAttribute>(ex, "Could not delete temp file {FileName}", f.TempFilePath);
Current.Logger.LogError(ex, "Could not delete temp file {FileName}", f.TempFilePath);
}
//clear out the temp path so it's not returned in the response

View File

@@ -91,7 +91,7 @@ namespace Umbraco.Web.WebAssets.CDF
}
catch (Exception ex)
{
_logger.LogError<ClientDependencyConfiguration>(ex, "Couldn't update ClientDependency version number");
_logger.LogError(ex, "Couldn't update ClientDependency version number");
}
return false;
@@ -124,7 +124,7 @@ namespace Umbraco.Web.WebAssets.CDF
catch (Exception ex)
{
//invalid path format or something... try/catch to be safe
_logger.LogError<ClientDependencyConfiguration>(ex, "Could not get path from ClientDependency.config");
_logger.LogError(ex, "Could not get path from ClientDependency.config");
}
var success = true;
@@ -140,7 +140,7 @@ namespace Umbraco.Web.WebAssets.CDF
catch (Exception ex)
{
// Something could be locking the directory or the was another error, making sure we don't break the upgrade installer
_logger.LogError<ClientDependencyConfiguration>(ex, "Could not clear temp files");
_logger.LogError(ex, "Could not clear temp files");
success = false;
}
}