diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs index 3df69392ca..3038326ea5 100755 --- a/src/Umbraco.Core/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs @@ -12,6 +12,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core.Exceptions; using Umbraco.Core.IO; using Umbraco.Core.Logging; +using Umbraco.Core.Logging.Serilog; using Umbraco.Core.Migrations.Upgrade; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Dtos; @@ -42,6 +43,15 @@ namespace Umbraco.Core.Runtime /// public virtual void Boot(ServiceContainer container) { + container.ConfigureUmbracoCore(); // also sets Current.Container + + // register the essential stuff, + // ie the global application logger + // (profiler etc depend on boot manager) + var logger = GetLogger(); + container.RegisterInstance(logger); + // now it is ok to use Current.Logger + Compose(container); // prepare essential stuff @@ -107,6 +117,14 @@ namespace Umbraco.Core.Runtime //sa.Scope?.Dispose(); } + /// + /// Gets a logger. + /// + protected virtual ILogger GetLogger() + { + return SerilogLogger.CreateWithDefaultConfiguration(); + } + private void AquireMainDom(IServiceFactory container) { using (var timer = ProfilingLogger.DebugDuration("Acquiring MainDom.", "Aquired.")) diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs index b3a96021b1..533e2f1a55 100755 --- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs +++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs @@ -64,14 +64,6 @@ namespace Umbraco.Tests.Runtimes return new TestRuntime(this); } - // the application's logger is created by the application - // through GetLogger, that custom application can override - protected override ILogger GetLogger() - { - //return Mock.Of(); - return new DebugDiagnosticsLogger(); - } - // don't register anything against AppDomain protected override void ConfigureUnhandledException(ILogger logger) { } @@ -86,6 +78,14 @@ namespace Umbraco.Tests.Runtimes _umbracoApplication = umbracoApplication; } + // the application's logger is created by the application + // through GetLogger, that custom application can override + protected override ILogger GetLogger() + { + //return Mock.Of(); + return new DebugDiagnosticsLogger(); + } + public override void Compose(ServiceContainer container) { base.Compose(container); diff --git a/src/Umbraco.Web/UmbracoApplicationBase.cs b/src/Umbraco.Web/UmbracoApplicationBase.cs index 7a88e61521..aa261ac55f 100755 --- a/src/Umbraco.Web/UmbracoApplicationBase.cs +++ b/src/Umbraco.Web/UmbracoApplicationBase.cs @@ -23,14 +23,6 @@ namespace Umbraco.Web /// protected abstract IRuntime GetRuntime(); - /// - /// Gets a logger. - /// - protected virtual ILogger GetLogger() - { - return SerilogLogger.CreateWithDefaultConfiguration(); - } - // events - in the order they trigger // were part of the BootManager architecture, would trigger only for the initial @@ -62,21 +54,15 @@ namespace Umbraco.Web // create the container for the application, and configure. // the boot manager is responsible for registrations var container = new ServiceContainer(); - container.ConfigureUmbracoCore(); // also sets Current.Container - - // register the essential stuff, - // ie the global application logger - // (profiler etc depend on boot manager) - var logger = GetLogger(); - container.RegisterInstance(logger); - // now it is ok to use Current.Logger - - ConfigureUnhandledException(logger); - ConfigureAssemblyResolve(logger); // get runtime & boot _runtime = GetRuntime(); _runtime.Boot(container); + + var logger = container.GetInstance(); + + ConfigureUnhandledException(logger); + ConfigureAssemblyResolve(logger); } protected virtual void ConfigureUnhandledException(ILogger logger)