diff --git a/src/Umbraco.Core/StaticApplicationLogging.cs b/src/Umbraco.Core/StaticApplicationLogging.cs index e216011014..0f32075144 100644 --- a/src/Umbraco.Core/StaticApplicationLogging.cs +++ b/src/Umbraco.Core/StaticApplicationLogging.cs @@ -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() ?? NullLoggerFactory.Instance.CreateLogger(); } + + public static ILogger CreateLogger(Type type) + { + return _loggerFactory?.CreateLogger(type) ?? NullLoggerFactory.Instance.CreateLogger(type); + } } } diff --git a/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs b/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs index 32e2ab188d..7686c357a4 100644 --- a/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs +++ b/src/Umbraco.Infrastructure/HostedServices/RecurringHostedServiceBase.cs @@ -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(), period, delay) { + _period = period; + _delay = delay; + _logger = StaticApplicationLogging.CreateLogger(GetType()); } ///