Add CreateLogger method so we still can get types using the legacy ctor

This commit is contained in:
Nikolaj Geisle
2022-03-22 14:52:39 +01:00
parent c6bfc61909
commit 3f7f2797a6
2 changed files with 9 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
using System;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
@@ -18,5 +19,10 @@ namespace Umbraco.Cms.Core
{
return _loggerFactory?.CreateLogger<T>() ?? NullLoggerFactory.Instance.CreateLogger<T>();
}
public static ILogger CreateLogger(Type type)
{
return _loggerFactory?.CreateLogger(type) ?? NullLoggerFactory.Instance.CreateLogger(type);
}
}
}

View File

@@ -45,8 +45,10 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
// Scheduled for removal in V11
[Obsolete("Please use constructor that takes an ILogger instead")]
protected RecurringHostedServiceBase(TimeSpan period, TimeSpan delay)
: this(StaticApplicationLogging.CreateLogger<RecurringHostedServiceBase>(), period, delay)
{
_period = period;
_delay = delay;
_logger = StaticApplicationLogging.CreateLogger(GetType());
}
/// <inheritdoc/>