From 02828db8fd3c6f6fec2fe703d1b921b9a96ac7cb Mon Sep 17 00:00:00 2001 From: Nikolaj Date: Tue, 15 Sep 2020 08:45:40 +0200 Subject: [PATCH] Add work on PublishedSnapshotService --- src/Umbraco.Core/Composing/Composers.cs | 24 ++++--- .../Configuration/XmlConfigManipulator.cs | 8 +-- .../ContentInfoContentAppFactory.cs | 6 +- src/Umbraco.Core/Logging/DisposableTimer.cs | 8 +-- src/Umbraco.Core/Logging/ILogger.cs | 2 +- src/Umbraco.Core/Logging/IProfilingLogger.cs | 2 +- src/Umbraco.Core/Logging/LogProfiler.cs | 2 +- src/Umbraco.Core/Logging/LoggerExtensions.cs | 4 +- src/Umbraco.Core/Logging/NullLogger.cs | 15 ---- src/Umbraco.Core/Logging/ProfilingLogger.cs | 15 +--- src/Umbraco.Core/Manifest/ManifestWatcher.cs | 2 +- src/Umbraco.Core/Runtime/MainDom.cs | 12 ++-- src/Umbraco.Core/Templates/HtmlUrlParser.cs | 12 ++-- src/Umbraco.Core/UriExtensions.cs | 2 +- .../ExamineExtensions.cs | 2 +- .../LuceneIndexDiagnostics.cs | 4 +- .../UmbracoContentIndex.cs | 10 ++- .../UmbracoExamineIndex.cs | 13 ++-- .../UmbracoExamineIndexDiagnostics.cs | 2 +- .../Cache/DistributedCacheBinder_Handlers.cs | 2 +- .../HealthCheck/HealthCheckResults.cs | 6 +- .../InstallSteps/DatabaseUpgradeStep.cs | 2 +- .../Migrations/Install/DatabaseBuilder.cs | 12 ++-- .../Migrations/Install/DatabaseDataCreator.cs | 4 +- .../Install/DatabaseSchemaCreator.cs | 20 +++--- .../Migrations/MigrationExpressionBase.cs | 4 +- .../Migrations/MigrationPlan.cs | 12 ++-- .../PublishedContentTypeCache.cs | 12 ++-- .../Runtime/CoreRuntime.cs | 2 +- .../Scheduling/BackgroundTaskRunner.cs | 8 +-- .../Scheduling/ScheduledPublishing.cs | 2 +- .../Search/BackgroundIndexRebuilder.cs | 2 +- .../Search/ExamineComponent.cs | 4 +- .../Services/Implement/ContentService.cs | 30 ++++---- src/Umbraco.Infrastructure/Suspendable.cs | 4 +- .../Sync/DatabaseServerMessenger.cs | 2 +- .../LiveModelsProvider.cs | 4 +- .../PureLiveModelFactory.cs | 47 +++++++------ .../ContentStore.cs | 51 +++++++------- .../PublishedSnapshotService.cs | 68 ++++++++++--------- .../LegacyXmlPublishedCache/XmlStore.cs | 12 ++-- .../Services/ContentServicePerformanceTest.cs | 2 +- .../Controllers/AuthenticationController.cs | 6 +- .../ExamineManagementController.cs | 6 +- .../Profiler/WebProfilerComponent.cs | 2 +- .../AspNet/AspNetBackOfficeInfo.cs | 2 +- src/Umbraco.Web/CdfLogger.cs | 2 +- src/Umbraco.Web/Logging/OwinLogger.cs | 14 ++-- .../Logging/WebProfilerComponent.cs | 2 +- .../Providers/UmbracoMembershipProvider.cs | 12 ++-- src/Umbraco.Web/UmbracoApplicationBase.cs | 4 +- .../CDF/ClientDependencyConfiguration.cs | 2 +- 52 files changed, 255 insertions(+), 254 deletions(-) diff --git a/src/Umbraco.Core/Composing/Composers.cs b/src/Umbraco.Core/Composing/Composers.cs index 86c994c557..93f6def891 100644 --- a/src/Umbraco.Core/Composing/Composers.cs +++ b/src/Umbraco.Core/Composing/Composers.cs @@ -16,7 +16,8 @@ namespace Umbraco.Core.Composing public class Composers { private readonly Composition _composition; - private readonly IProfilingLogger _logger; + private readonly ILogger _logger; + private readonly IProfilingLogger _profileLogger; private readonly IEnumerable _composerTypes; private readonly IEnumerable _enableDisableAttributes; @@ -28,7 +29,8 @@ namespace Umbraco.Core.Composing /// The composition. /// The types. /// The and/or attributes. - /// The profiling logger. + /// The logger. + /// The profiling logger. /// composition /// or /// composerTypes @@ -36,13 +38,13 @@ namespace Umbraco.Core.Composing /// enableDisableAttributes /// or /// logger - - public Composers(Composition composition, IEnumerable composerTypes, IEnumerable enableDisableAttributes, IProfilingLogger logger) + public Composers(Composition composition, IEnumerable composerTypes, IEnumerable enableDisableAttributes, ILogger logger, IProfilingLogger profileLogger) { _composition = composition ?? throw new ArgumentNullException(nameof(composition)); _composerTypes = composerTypes ?? throw new ArgumentNullException(nameof(composerTypes)); _enableDisableAttributes = enableDisableAttributes ?? throw new ArgumentNullException(nameof(enableDisableAttributes)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + _profileLogger = profileLogger; } private class EnableInfo @@ -61,19 +63,19 @@ namespace Umbraco.Core.Composing IEnumerable orderedComposerTypes; - using (_logger.DebugDuration("Preparing composer types.", "Prepared composer types.")) + using (_profileLogger.DebugDuration("Preparing composer types.", "Prepared composer types.")) { orderedComposerTypes = PrepareComposerTypes(); } var composers = InstantiateComposers(orderedComposerTypes); - using (_logger.DebugDuration($"Composing composers. (log when >{LogThresholdMilliseconds}ms)", "Composed composers.")) + using (_profileLogger.DebugDuration($"Composing composers. (log when >{LogThresholdMilliseconds}ms)", "Composed composers.")) { foreach (var composer in composers) { var componentType = composer.GetType(); - using (_logger.DebugDuration($"Composing {componentType.FullName}.", $"Composed {componentType.FullName}.", thresholdMilliseconds: LogThresholdMilliseconds)) + using (_profileLogger.DebugDuration($"Composing {componentType.FullName}.", $"Composed {componentType.FullName}.", thresholdMilliseconds: LogThresholdMilliseconds)) { composer.Compose(_composition); } @@ -92,7 +94,7 @@ namespace Umbraco.Core.Composing // bit verbose but should help for troubleshooting //var text = "Ordered Composers: " + Environment.NewLine + string.Join(Environment.NewLine, sortedComposerTypes) + Environment.NewLine; - _logger.Debug("Ordered Composers: {SortedComposerTypes}", sortedComposerTypes); + _logger.LogDebug("Ordered Composers: {SortedComposerTypes}", sortedComposerTypes); return sortedComposerTypes; } @@ -183,8 +185,8 @@ namespace Umbraco.Core.Composing catch (Exception e) { // in case of an error, force-dump everything to log - _logger.Info("Composer Report:\r\n{ComposerReport}", GetComposersReport(requirements)); - _logger.LogError(e, "Failed to sort composers."); + _logger.LogInformation("Composer Report:\r\n{ComposerReport}", GetComposersReport(requirements)); + _logger.LogError(e, "Failed to sort composers."); throw; } @@ -370,7 +372,7 @@ namespace Umbraco.Core.Composing return (IComposer) ctor.Invoke(Array.Empty()); } - using (_logger.DebugDuration("Instantiating composers.", "Instantiated composers.")) + using (_profileLogger.DebugDuration("Instantiating composers.", "Instantiated composers.")) { return types.Select(InstantiateComposer).ToArray(); } diff --git a/src/Umbraco.Core/Configuration/XmlConfigManipulator.cs b/src/Umbraco.Core/Configuration/XmlConfigManipulator.cs index dd7e4baa94..65744f49d8 100644 --- a/src/Umbraco.Core/Configuration/XmlConfigManipulator.cs +++ b/src/Umbraco.Core/Configuration/XmlConfigManipulator.cs @@ -12,9 +12,9 @@ namespace Umbraco.Core.Configuration public class XmlConfigManipulator : IConfigManipulator { private readonly IIOHelper _ioHelper; - private readonly ILogger _logger; + private readonly ILogger _logger; - public XmlConfigManipulator(IIOHelper ioHelper, ILogger logger) + public XmlConfigManipulator(IIOHelper ioHelper, ILogger logger) { _ioHelper = ioHelper; _logger = logger; @@ -101,9 +101,9 @@ namespace Umbraco.Core.Configuration } // save - _logger.Info("Saving connection string to {ConfigFile}.", fileSource); + _logger.LogInformation("Saving connection string to {ConfigFile}.", fileSource); xml.Save(fileName, SaveOptions.DisableFormatting); - _logger.Info("Saved connection string to {ConfigFile}.", fileSource); + _logger.LogInformation("Saved connection string to {ConfigFile}.", fileSource); } public void SaveConfigValue(string itemPath, object value) diff --git a/src/Umbraco.Core/ContentApps/ContentInfoContentAppFactory.cs b/src/Umbraco.Core/ContentApps/ContentInfoContentAppFactory.cs index abad7f4bf8..56774d652d 100644 --- a/src/Umbraco.Core/ContentApps/ContentInfoContentAppFactory.cs +++ b/src/Umbraco.Core/ContentApps/ContentInfoContentAppFactory.cs @@ -23,7 +23,7 @@ namespace Umbraco.Web.ContentApps return _contentApp ?? (_contentApp = new ContentApp { Alias = "umbInfo", - Name = "Info", + Name = "LogInformation", Icon = "icon-info", View = "views/content/apps/info/info.html", Weight = Weight @@ -33,7 +33,7 @@ namespace Umbraco.Web.ContentApps return _mediaApp ?? (_mediaApp = new ContentApp { Alias = "umbInfo", - Name = "Info", + Name = "LogInformation", Icon = "icon-info", View = "views/media/apps/info/info.html", Weight = Weight @@ -42,7 +42,7 @@ namespace Umbraco.Web.ContentApps return _memberApp ?? (_memberApp = new ContentApp { Alias = "umbInfo", - Name = "Info", + Name = "LogInformation", Icon = "icon-info", View = "views/member/apps/info/info.html", Weight = Weight diff --git a/src/Umbraco.Core/Logging/DisposableTimer.cs b/src/Umbraco.Core/Logging/DisposableTimer.cs index 7fd3f62987..a7dfbd254f 100644 --- a/src/Umbraco.Core/Logging/DisposableTimer.cs +++ b/src/Umbraco.Core/Logging/DisposableTimer.cs @@ -37,10 +37,10 @@ namespace Umbraco.Core.Logging switch (_level) { case LogLevel.Debug: - logger.Debug("{StartMessage} [Timing {TimingId}]", startMessage, _timingId); + logger.LogDebug("{StartMessage} [Timing {TimingId}]", startMessage, _timingId); break; case LogLevel.Information: - logger.Info("{StartMessage} [Timing {TimingId}]", startMessage, _timingId); + logger.LogInformation("{StartMessage} [Timing {TimingId}]", startMessage, _timingId); break; default: throw new ArgumentOutOfRangeException(nameof(level)); @@ -89,10 +89,10 @@ namespace Umbraco.Core.Logging else switch (_level) { case LogLevel.Debug: - _logger.Debug("{EndMessage} ({Duration}ms) [Timing {TimingId}]", _endMessage, Stopwatch.ElapsedMilliseconds, _timingId); + _logger.LogDebug("{EndMessage} ({Duration}ms) [Timing {TimingId}]", _endMessage, Stopwatch.ElapsedMilliseconds, _timingId); break; case LogLevel.Information: - _logger.Info("{EndMessage} ({Duration}ms) [Timing {TimingId}]", _endMessage, Stopwatch.ElapsedMilliseconds, _timingId); + _logger.LogInformation("{EndMessage} ({Duration}ms) [Timing {TimingId}]", _endMessage, Stopwatch.ElapsedMilliseconds, _timingId); break; // filtered in the ctor //default: diff --git a/src/Umbraco.Core/Logging/ILogger.cs b/src/Umbraco.Core/Logging/ILogger.cs index 10926eecca..da590c6bba 100644 --- a/src/Umbraco.Core/Logging/ILogger.cs +++ b/src/Umbraco.Core/Logging/ILogger.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.Logging /// specification includes support for traditional C# numeric placeholders. /// For instance, "Processed {Input} in {Time}ms." /// - public interface ILogger + public interface ILogger { /// /// Determines if logging is enabled at a specified level, for a reporting type. diff --git a/src/Umbraco.Core/Logging/IProfilingLogger.cs b/src/Umbraco.Core/Logging/IProfilingLogger.cs index 1d7c231e95..019b43d61e 100644 --- a/src/Umbraco.Core/Logging/IProfilingLogger.cs +++ b/src/Umbraco.Core/Logging/IProfilingLogger.cs @@ -5,7 +5,7 @@ namespace Umbraco.Core.Logging /// /// Defines the profiling logging service. /// - public interface IProfilingLogger : ILogger + public interface IProfilingLogger { /// /// Profiles an action and log as information messages. diff --git a/src/Umbraco.Core/Logging/LogProfiler.cs b/src/Umbraco.Core/Logging/LogProfiler.cs index a1d2a2e61f..81e250895b 100644 --- a/src/Umbraco.Core/Logging/LogProfiler.cs +++ b/src/Umbraco.Core/Logging/LogProfiler.cs @@ -19,7 +19,7 @@ namespace Umbraco.Core.Logging public IDisposable Step(string name) { _logger.Debug("Begin: {ProfileName}", name); - return new LightDisposableTimer(duration => _logger.Info("End {ProfileName} ({ProfileDuration}ms)", name, duration)); + return new LightDisposableTimer(duration => _logger.LogInformation("End {ProfileName} ({ProfileDuration}ms)", name, duration)); } /// diff --git a/src/Umbraco.Core/Logging/LoggerExtensions.cs b/src/Umbraco.Core/Logging/LoggerExtensions.cs index ddcd3b450b..efc17fd623 100644 --- a/src/Umbraco.Core/Logging/LoggerExtensions.cs +++ b/src/Umbraco.Core/Logging/LoggerExtensions.cs @@ -102,7 +102,7 @@ namespace Umbraco.Core.Logging /// The reporting type. /// The logger. /// A message. - public static void Info(this ILogger logger, string message) + public static void LogInformation(this ILogger logger, string message) => logger.LogInformation(message); /// @@ -112,7 +112,7 @@ namespace Umbraco.Core.Logging /// The logger. /// A message template. /// Property values. - public static void Info(this ILogger logger, string messageTemplate, params object[] propertyValues) + public static void LogInformation(this ILogger logger, string messageTemplate, params object[] propertyValues) => logger.LogInformation(messageTemplate, propertyValues); /// diff --git a/src/Umbraco.Core/Logging/NullLogger.cs b/src/Umbraco.Core/Logging/NullLogger.cs index ef2df582a6..892675bc47 100644 --- a/src/Umbraco.Core/Logging/NullLogger.cs +++ b/src/Umbraco.Core/Logging/NullLogger.cs @@ -46,31 +46,16 @@ namespace Umbraco.Core.Logging } - public void LogInformation(string message, params object[] propertyValues) - { - - } - public void LogInformation(string messageTemplate, params object[] propertyValues) { } - public void LogDebug(string message, params object[] propertyValues) - { - - } - public void LogDebug(string messageTemplate, params object[] propertyValues) { } - public void LogTrace(string message, params object[] propertyValues) - { - - } - public void LogTrace(string messageTemplate, params object[] propertyValues) { diff --git a/src/Umbraco.Core/Logging/ProfilingLogger.cs b/src/Umbraco.Core/Logging/ProfilingLogger.cs index 5164f0f067..6611a81123 100644 --- a/src/Umbraco.Core/Logging/ProfilingLogger.cs +++ b/src/Umbraco.Core/Logging/ProfilingLogger.cs @@ -85,23 +85,14 @@ namespace Umbraco.Core.Logging public void LogWarning(Exception exception, string messageTemplate, params object[] propertyValues) => Logger.LogWarning(exception, messageTemplate, propertyValues); - public void LogInformation(string message, params object[] propertyValues) - => Logger.LogInformation(message, propertyValues); - public void LogInformation(string messageTemplate, params object[] propertyValues) - => Logger.Info(messageTemplate, propertyValues); - - public void LogDebug(string message, params object[] propertyValues) - => Logger.LogDebug(message, propertyValues); + => Logger.LogInformation(messageTemplate, propertyValues); public void LogDebug(string messageTemplate, params object[] propertyValues) - => Logger.Debug(messageTemplate, propertyValues); - - public void LogTrace(string message, params object[] propertyValues) - => Logger.LogTrace(message, propertyValues); + => Logger.LogDebug(messageTemplate, propertyValues); public void LogTrace(string messageTemplate, params object[] propertyValues) - => Logger.Verbose(messageTemplate, propertyValues); + => Logger.LogTrace(messageTemplate, propertyValues); #endregion } diff --git a/src/Umbraco.Core/Manifest/ManifestWatcher.cs b/src/Umbraco.Core/Manifest/ManifestWatcher.cs index 23caac3a1b..38b9a30190 100644 --- a/src/Umbraco.Core/Manifest/ManifestWatcher.cs +++ b/src/Umbraco.Core/Manifest/ManifestWatcher.cs @@ -57,7 +57,7 @@ namespace Umbraco.Core.Manifest if (_isRestarting) return; _isRestarting = true; - _logger.Info("Manifest has changed, app pool is restarting ({Path})", e.FullPath); + _logger.LogInformation("Manifest has changed, app pool is restarting ({Path})", e.FullPath); _umbracoApplicationLifetime.Restart(); Dispose(); // uh? if the app restarts then this should be disposed anyways? } diff --git a/src/Umbraco.Core/Runtime/MainDom.cs b/src/Umbraco.Core/Runtime/MainDom.cs index d4aa5d9518..1a81a2fb71 100644 --- a/src/Umbraco.Core/Runtime/MainDom.cs +++ b/src/Umbraco.Core/Runtime/MainDom.cs @@ -112,7 +112,7 @@ namespace Umbraco.Core.Runtime try { - _logger.Info("Stopping ({SignalSource})", source); + _logger.LogInformation("Stopping ({SignalSource})", source); foreach (var callback in _callbacks.OrderBy(x => x.Key).Select(x => x.Value)) { try @@ -133,7 +133,7 @@ namespace Umbraco.Core.Runtime // in any case... _isMainDom = false; _mainDomLock.Dispose(); - _logger.Info("Released ({SignalSource})", source); + _logger.LogInformation("Released ({SignalSource})", source); } } @@ -146,18 +146,18 @@ namespace Umbraco.Core.Runtime // the handler is not installed so that would be the hosting environment if (_signaled) { - _logger.Info("Cannot acquire (signaled)."); + _logger.LogInformation("Cannot acquire (signaled)."); return false; } - _logger.Info("Acquiring."); + _logger.LogInformation("Acquiring."); // Get the lock var acquired = _mainDomLock.AcquireLockAsync(LockTimeoutMilliseconds).GetAwaiter().GetResult(); if (!acquired) { - _logger.Info("Cannot acquire (timeout)."); + _logger.LogInformation("Cannot acquire (timeout)."); // In previous versions we'd let a TimeoutException be thrown // and the appdomain would not start. We have the opportunity to allow it to @@ -180,7 +180,7 @@ namespace Umbraco.Core.Runtime _logger.LogWarning(ex, ex.Message); } - _logger.Info("Acquired."); + _logger.LogInformation("Acquired."); return true; } diff --git a/src/Umbraco.Core/Templates/HtmlUrlParser.cs b/src/Umbraco.Core/Templates/HtmlUrlParser.cs index ff89b9dc59..b06c7524a1 100644 --- a/src/Umbraco.Core/Templates/HtmlUrlParser.cs +++ b/src/Umbraco.Core/Templates/HtmlUrlParser.cs @@ -8,17 +8,19 @@ namespace Umbraco.Web.Templates public sealed class HtmlUrlParser { private readonly IContentSettings _contentSettings; + private readonly ILogger _logger; private readonly IIOHelper _ioHelper; - private readonly IProfilingLogger _logger; + private readonly IProfilingLogger _profilingLogger; private static readonly Regex ResolveUrlPattern = new Regex("(=[\"\']?)(\\W?\\~(?:.(?![\"\']?\\s+(?:\\S+)=|[>\"\']))+.)[\"\']?", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); - public HtmlUrlParser(IContentSettings contentSettings, IProfilingLogger logger, IIOHelper ioHelper) + public HtmlUrlParser(IContentSettings contentSettings, ILogger logger ,IProfilingLogger profilingLogger, IIOHelper ioHelper) { _contentSettings = contentSettings; - _ioHelper = ioHelper; _logger = logger; + _ioHelper = ioHelper; + _profilingLogger = profilingLogger; } /// @@ -34,11 +36,11 @@ namespace Umbraco.Web.Templates { if (_contentSettings.ResolveUrlsFromTextString == false) return text; - using (var timer = _logger.DebugDuration(typeof(IOHelper), "ResolveUrlsFromTextString starting", "ResolveUrlsFromTextString complete")) + using (var timer = _profilingLogger.DebugDuration(typeof(IOHelper), "ResolveUrlsFromTextString starting", "ResolveUrlsFromTextString complete")) { // find all relative urls (ie. urls that contain ~) var tags = ResolveUrlPattern.Matches(text); - _logger.Debug("After regex: {Duration} matched: {TagsCount}", timer.Stopwatch.ElapsedMilliseconds, tags.Count); + _logger.LogDebug("After regex: {Duration} matched: {TagsCount}", timer.Stopwatch.ElapsedMilliseconds, tags.Count); foreach (Match tag in tags) { var url = ""; diff --git a/src/Umbraco.Core/UriExtensions.cs b/src/Umbraco.Core/UriExtensions.cs index 456ae9fa2a..5ecbc38183 100644 --- a/src/Umbraco.Core/UriExtensions.cs +++ b/src/Umbraco.Core/UriExtensions.cs @@ -159,7 +159,7 @@ namespace Umbraco.Core } catch (ArgumentException) { - Current.Logger.Debug("Failed to determine if request was client side (invalid chars in path \"{Path}\"?)", url.LocalPath); + Current.Logger.LogDebug("Failed to determine if request was client side (invalid chars in path \"{Path}\"?)", url.LocalPath); return false; } } diff --git a/src/Umbraco.Examine.Lucene/ExamineExtensions.cs b/src/Umbraco.Examine.Lucene/ExamineExtensions.cs index 6d23f15a27..0f8c1ecda9 100644 --- a/src/Umbraco.Examine.Lucene/ExamineExtensions.cs +++ b/src/Umbraco.Examine.Lucene/ExamineExtensions.cs @@ -87,7 +87,7 @@ namespace Umbraco.Examine var dir = luceneIndexer.GetLuceneDirectory(); if (IndexWriter.IsLocked(dir)) { - logger.Info("Forcing index {IndexerName} to be unlocked since it was left in a locked state", luceneIndexer.Name); + logger.LogDebug("Forcing index {IndexerName} to be unlocked since it was left in a locked state", luceneIndexer.Name); IndexWriter.Unlock(dir); } } diff --git a/src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs b/src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs index 341eb67772..a8e185d01c 100644 --- a/src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs +++ b/src/Umbraco.Examine.Lucene/LuceneIndexDiagnostics.cs @@ -14,7 +14,7 @@ namespace Umbraco.Examine { private readonly IHostingEnvironment _hostingEnvironment; - public LuceneIndexDiagnostics(LuceneIndex index, ILogger logger, IHostingEnvironment hostingEnvironment) + public LuceneIndexDiagnostics(LuceneIndex index, ILogger logger, IHostingEnvironment hostingEnvironment) { _hostingEnvironment = hostingEnvironment; Index = index; @@ -22,7 +22,7 @@ namespace Umbraco.Examine } public LuceneIndex Index { get; } - public ILogger Logger { get; } + public ILogger Logger { get; } public int DocumentCount { diff --git a/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs index 0e9b35ca41..028adb8912 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoContentIndex.cs @@ -21,6 +21,7 @@ namespace Umbraco.Examine /// public class UmbracoContentIndex : UmbracoExamineIndex, IUmbracoContentIndex, IDisposable { + private readonly ILogger _logger; protected ILocalizationService LanguageService { get; } #region Constructors @@ -33,6 +34,7 @@ namespace Umbraco.Examine /// /// /// + /// /// /// /// @@ -44,14 +46,18 @@ namespace Umbraco.Examine FieldDefinitionCollection fieldDefinitions, Analyzer defaultAnalyzer, IProfilingLogger profilingLogger, + ILogger logger, + ILogger examineIndexLogger, + ILogger examineIndexDiagnosticsLogger, IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState, ILocalizationService languageService, IContentValueSetValidator validator, IReadOnlyDictionary indexValueTypes = null) - : base(name, luceneDirectory, fieldDefinitions, defaultAnalyzer, profilingLogger, hostingEnvironment, runtimeState, validator, indexValueTypes) + : base(name, luceneDirectory, fieldDefinitions, defaultAnalyzer, profilingLogger, examineIndexLogger, examineIndexDiagnosticsLogger ,hostingEnvironment, runtimeState, validator, indexValueTypes) { if (validator == null) throw new ArgumentNullException(nameof(validator)); + _logger = logger; LanguageService = languageService ?? throw new ArgumentNullException(nameof(languageService)); if (validator is IContentValueSetValidator contentValueSetValidator) @@ -138,7 +144,7 @@ namespace Umbraco.Examine var filtered = c.NativeQuery(rawQuery); var results = filtered.Execute(); - ProfilingLogger.Debug("DeleteFromIndex with query: {Query} (found {TotalItems} results)", rawQuery, results.TotalItemCount); + _logger.LogDebug("DeleteFromIndex with query: {Query} (found {TotalItems} results)", rawQuery, results.TotalItemCount); //need to queue a delete item for each one found QueueIndexOperation(results.Select(r => new IndexOperation(new ValueSet(r.Id), IndexOperationType.Delete))); diff --git a/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs index a911e2553d..a04e3cd10f 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs @@ -22,6 +22,8 @@ namespace Umbraco.Examine /// public abstract class UmbracoExamineIndex : LuceneIndex, IUmbracoIndex, IIndexDiagnostics { + private readonly ILogger _logger; + private readonly IRuntimeState _runtimeState; // note // wrapping all operations that end up calling base.SafelyProcessQueueItems in a safe call @@ -29,7 +31,6 @@ namespace Umbraco.Examine // call context (and the database it can contain)! ideally we should be able to override // SafelyProcessQueueItems but that's not possible in the current version of Examine. - /// /// Create a new @@ -39,6 +40,7 @@ namespace Umbraco.Examine /// /// /// + /// /// /// /// @@ -49,12 +51,15 @@ namespace Umbraco.Examine FieldDefinitionCollection fieldDefinitions, Analyzer defaultAnalyzer, IProfilingLogger profilingLogger, + ILogger _logger, + ILogger _examineIndexLogger, IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState, IValueSetValidator validator = null, IReadOnlyDictionary indexValueTypes = null) : base(name, luceneDirectory, fieldDefinitions, defaultAnalyzer, validator, indexValueTypes) { + this._logger = _logger; _runtimeState = runtimeState; ProfilingLogger = profilingLogger ?? throw new ArgumentNullException(nameof(profilingLogger)); @@ -62,7 +67,7 @@ namespace Umbraco.Examine if (luceneDirectory is FSDirectory fsDir) LuceneIndexFolder = fsDir.Directory; - _diagnostics = new UmbracoExamineIndexDiagnostics(this, ProfilingLogger, hostingEnvironment); + _diagnostics = new UmbracoExamineIndexDiagnostics(this, _examineIndexLogger, hostingEnvironment); } private readonly bool _configBased = false; @@ -118,7 +123,7 @@ namespace Umbraco.Examine /// protected override void OnIndexingError(IndexingErrorEventArgs ex) { - ProfilingLogger.LogError(ex.InnerException, ex.Message); + _logger.LogError(ex.InnerException, ex.Message); base.OnIndexingError(ex); } @@ -154,7 +159,7 @@ namespace Umbraco.Examine /// protected override void AddDocument(Document doc, ValueSet valueSet, IndexWriter writer) { - ProfilingLogger.Debug("Write lucene doc id:{DocumentId}, category:{DocumentCategory}, type:{DocumentItemType}", + _logger.LogDebug("Write lucene doc id:{DocumentId}, category:{DocumentCategory}, type:{DocumentItemType}", valueSet.Id, valueSet.Category, valueSet.ItemType); diff --git a/src/Umbraco.Examine.Lucene/UmbracoExamineIndexDiagnostics.cs b/src/Umbraco.Examine.Lucene/UmbracoExamineIndexDiagnostics.cs index 777b198232..f6abb9bd26 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoExamineIndexDiagnostics.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoExamineIndexDiagnostics.cs @@ -12,7 +12,7 @@ namespace Umbraco.Examine { private readonly UmbracoExamineIndex _index; - public UmbracoExamineIndexDiagnostics(UmbracoExamineIndex index, ILogger logger, IHostingEnvironment hostingEnvironment) + public UmbracoExamineIndexDiagnostics(UmbracoExamineIndex index, ILogger logger, IHostingEnvironment hostingEnvironment) : base(index, logger, hostingEnvironment) { _index = index; diff --git a/src/Umbraco.Infrastructure/Cache/DistributedCacheBinder_Handlers.cs b/src/Umbraco.Infrastructure/Cache/DistributedCacheBinder_Handlers.cs index c0200933ab..ed9c7cc490 100644 --- a/src/Umbraco.Infrastructure/Cache/DistributedCacheBinder_Handlers.cs +++ b/src/Umbraco.Infrastructure/Cache/DistributedCacheBinder_Handlers.cs @@ -43,7 +43,7 @@ namespace Umbraco.Web.Cache if (supportUnbinding) _unbinders = new List(); - _logger.Info("Initializing Umbraco internal event handlers for cache refreshing."); + _logger.LogInformation("Initializing Umbraco internal event handlers for cache refreshing."); // bind to user and user group events Bind(() => UserService.SavedUserGroup += UserService_SavedUserGroup, diff --git a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs b/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs index a14c59866f..33cb0f204f 100644 --- a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs +++ b/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs @@ -54,7 +54,7 @@ namespace Umbraco.Web.HealthCheck public void LogResults() { - Logger.Info("Scheduled health check results:"); + Logger.LogInformation("Scheduled health check results:"); foreach (var result in _results) { var checkName = result.Key; @@ -62,7 +62,7 @@ namespace Umbraco.Web.HealthCheck var checkIsSuccess = result.Value.All(x => x.ResultType == StatusResultType.Success); if (checkIsSuccess) { - Logger.Info("Checks for '{HealthCheckName}' all completed successfully.", checkName); + Logger.LogInformation("Checks for '{HealthCheckName}' all completed successfully.", checkName); } else { @@ -71,7 +71,7 @@ namespace Umbraco.Web.HealthCheck foreach (var checkResult in checkResults) { - Logger.Info("Result for {HealthCheckName}: {HealthCheckResult}, Message: '{HealthCheckMessage}'", checkName, checkResult.ResultType, checkResult.Message); + Logger.LogInformation("Result for {HealthCheckName}: {HealthCheckResult}, Message: '{HealthCheckMessage}'", checkName, checkResult.ResultType, checkResult.Message); } } } diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs index dccf320787..02e852eb90 100644 --- a/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs +++ b/src/Umbraco.Infrastructure/Install/InstallSteps/DatabaseUpgradeStep.cs @@ -53,7 +53,7 @@ namespace Umbraco.Web.Install.InstallSteps if (upgrade) { - _logger.Info("Running 'Upgrade' service"); + _logger.LogInformation("Running 'Upgrade' service"); var plan = new UmbracoPlan(_umbracoVersion, _globalSettings); plan.AddPostMigration(); // needed when running installer (back-office) diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs index b5ff8f1c19..1cc8115664 100644 --- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs +++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs @@ -351,7 +351,7 @@ namespace Umbraco.Core.Migrations.Install return readyForInstall.Result; } - _logger.Info("Database configuration status: Started"); + _logger.LogInformation("Database configuration status: Started"); var database = scope.Database; @@ -373,12 +373,12 @@ namespace Umbraco.Core.Migrations.Install message = message + "

Installation completed!

"; //now that everything is done, we need to determine the version of SQL server that is executing - _logger.Info("Database configuration status: {DbConfigStatus}", message); + _logger.LogInformation("Database configuration status: {DbConfigStatus}", message); return new Result { Message = message, Success = true, Percentage = "100" }; } //we need to do an upgrade so return a new status message and it will need to be done during the next step - _logger.Info("Database requires upgrade"); + _logger.LogInformation("Database requires upgrade"); message = "

Upgrading database, this may take some time...

"; return new Result { @@ -412,7 +412,7 @@ namespace Umbraco.Core.Migrations.Install return readyForInstall.Result; } - _logger.Info("Database upgrade started"); + _logger.LogInformation("Database upgrade started"); // upgrade var upgrader = new Upgrader(plan); @@ -422,7 +422,7 @@ namespace Umbraco.Core.Migrations.Install //now that everything is done, we need to determine the version of SQL server that is executing - _logger.Info("Database configuration status: {DbConfigStatus}", message); + _logger.LogInformation("Database configuration status: {DbConfigStatus}", message); return new Result { Message = message, Success = true, Percentage = "100" }; } @@ -453,7 +453,7 @@ namespace Umbraco.Core.Migrations.Install if (_databaseSchemaValidationResult != null) { - _logger.Info("The database schema validation produced the following summary: {DbSchemaSummary}", _databaseSchemaValidationResult.GetSummary()); + _logger.LogInformation("The database schema validation produced the following summary: {DbSchemaSummary}", _databaseSchemaValidationResult.GetSummary()); } return new Result diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs index 36f1a30b20..b3ce6292d2 100644 --- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs +++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs @@ -33,7 +33,7 @@ namespace Umbraco.Core.Migrations.Install /// Name of the table to create base data for public void InitializeBaseData(string tableName) { - _logger.Info("Creating data in {TableName}", tableName); + _logger.LogInformation("Creating data in {TableName}", tableName); if (tableName.Equals(Constants.DatabaseSchema.Tables.Node)) CreateNodeData(); @@ -77,7 +77,7 @@ namespace Umbraco.Core.Migrations.Install if (tableName.Equals(Constants.DatabaseSchema.Tables.KeyValue)) CreateKeyValueData(); - _logger.Info("Done creating table {TableName} data.", tableName); + _logger.LogInformation("Done creating table {TableName} data.", tableName); } private void CreateNodeData() diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs index d133819ec9..a7417eacb6 100644 --- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs +++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs @@ -93,14 +93,14 @@ namespace Umbraco.Core.Migrations.Install ///
internal void UninstallDatabaseSchema() { - _logger.Info("Start UninstallDatabaseSchema"); + _logger.LogInformation("Start UninstallDatabaseSchema"); foreach (var table in OrderedTables.AsEnumerable().Reverse()) { var tableNameAttribute = table.FirstAttribute(); var tableName = tableNameAttribute == null ? table.Name : tableNameAttribute.Value; - _logger.Info("Uninstall {TableName}", tableName); + _logger.LogInformation("Uninstall {TableName}", tableName); try { @@ -436,7 +436,7 @@ namespace Umbraco.Core.Migrations.Install var tableExist = TableExists(tableName); if (overwrite && tableExist) { - _logger.Info("Table {TableName} already exists, but will be recreated", tableName); + _logger.LogInformation("Table {TableName} already exists, but will be recreated", tableName); DropTable(tableName); tableExist = false; @@ -445,19 +445,19 @@ namespace Umbraco.Core.Migrations.Install if (tableExist) { // The table exists and was not recreated/overwritten. - _logger.Info("Table {TableName} already exists - no changes were made", tableName); + _logger.LogInformation("Table {TableName} already exists - no changes were made", tableName); return; } //Execute the Create Table sql var created = _database.Execute(new Sql(createSql)); - _logger.Info("Create Table {TableName} ({Created}): \n {Sql}", tableName, created, createSql); + _logger.LogInformation("Create Table {TableName} ({Created}): \n {Sql}", tableName, created, createSql); //If any statements exists for the primary key execute them here if (string.IsNullOrEmpty(createPrimaryKeySql) == false) { var createdPk = _database.Execute(new Sql(createPrimaryKeySql)); - _logger.Info("Create Primary Key ({CreatedPk}):\n {Sql}", createdPk, createPrimaryKeySql); + _logger.LogInformation("Create Primary Key ({CreatedPk}):\n {Sql}", createdPk, createPrimaryKeySql); } if (SqlSyntax.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity)) @@ -475,23 +475,23 @@ namespace Umbraco.Core.Migrations.Install foreach (var sql in indexSql) { var createdIndex = _database.Execute(new Sql(sql)); - _logger.Info("Create Index ({CreatedIndex}):\n {Sql}", createdIndex, sql); + _logger.LogInformation("Create Index ({CreatedIndex}):\n {Sql}", createdIndex, sql); } //Loop through foreignkey statements and execute sql foreach (var sql in foreignSql) { var createdFk = _database.Execute(new Sql(sql)); - _logger.Info("Create Foreign Key ({CreatedFk}):\n {Sql}", createdFk, sql); + _logger.LogInformation("Create Foreign Key ({CreatedFk}):\n {Sql}", createdFk, sql); } if (overwrite) { - _logger.Info("Table {TableName} was recreated", tableName); + _logger.LogInformation("Table {TableName} was recreated", tableName); } else { - _logger.Info("New table {TableName} was created", tableName); + _logger.LogInformation("New table {TableName} was created", tableName); } } diff --git a/src/Umbraco.Infrastructure/Migrations/MigrationExpressionBase.cs b/src/Umbraco.Infrastructure/Migrations/MigrationExpressionBase.cs index 63fddae99e..42d2338eaa 100644 --- a/src/Umbraco.Infrastructure/Migrations/MigrationExpressionBase.cs +++ b/src/Umbraco.Infrastructure/Migrations/MigrationExpressionBase.cs @@ -55,7 +55,7 @@ namespace Umbraco.Core.Migrations if (string.IsNullOrWhiteSpace(sql)) { - Logger.Info("SQL [{ContextIndex}]: ", Context.Index); + LoggerExtensions.LogInformation(Logger, "SQL [{ContextIndex}]: ", Context.Index); } else { @@ -116,7 +116,7 @@ namespace Umbraco.Core.Migrations private void ExecuteStatement(StringBuilder stmtBuilder) { var stmt = stmtBuilder.ToString(); - Logger.Info("SQL [{ContextIndex}]: {Sql}", Context.Index, stmt); + LoggerExtensions.LogInformation(Logger, "SQL [{ContextIndex}]: {Sql}", Context.Index, stmt); Database.Execute(stmt); stmtBuilder.Clear(); } diff --git a/src/Umbraco.Infrastructure/Migrations/MigrationPlan.cs b/src/Umbraco.Infrastructure/Migrations/MigrationPlan.cs index 89c3c809e8..de2770bf47 100644 --- a/src/Umbraco.Infrastructure/Migrations/MigrationPlan.cs +++ b/src/Umbraco.Infrastructure/Migrations/MigrationPlan.cs @@ -294,11 +294,11 @@ namespace Umbraco.Core.Migrations if (migrationBuilder == null) throw new ArgumentNullException(nameof(migrationBuilder)); if (logger == null) throw new ArgumentNullException(nameof(logger)); - logger.Info("Starting '{MigrationName}'...", Name); + logger.LogInformation("Starting '{MigrationName}'...", Name); var origState = fromState ?? string.Empty; - logger.Info("At {OrigState}", string.IsNullOrWhiteSpace(origState) ? "origin": origState); + logger.LogInformation("At {OrigState}", string.IsNullOrWhiteSpace(origState) ? "origin": origState); if (!_transitions.TryGetValue(origState, out var transition)) ThrowOnUnknownInitialState(origState); @@ -308,7 +308,7 @@ namespace Umbraco.Core.Migrations while (transition != null) { - logger.Info("Execute {MigrationType}", transition.MigrationType.Name); + logger.LogInformation("Execute {MigrationType}", transition.MigrationType.Name); var migration = migrationBuilder.Build(transition.MigrationType, context); migration.Migrate(); @@ -316,7 +316,7 @@ namespace Umbraco.Core.Migrations var nextState = transition.TargetState; origState = nextState; - logger.Info("At {OrigState}", origState); + logger.LogInformation("At {OrigState}", origState); // throw a raw exception here: this should never happen as the plan has // been validated - this is just a paranoid safety test @@ -333,12 +333,12 @@ namespace Umbraco.Core.Migrations // run post-migrations foreach (var postMigrationType in postMigrationTypes) { - logger.Info($"PostMigration: {postMigrationType.FullName}."); + logger.LogInformation($"PostMigration: {postMigrationType.FullName}."); var postMigration = migrationBuilder.Build(postMigrationType, context); postMigration.Migrate(); } - logger.Info("Done (pending scope completion)."); + logger.LogInformation("Done (pending scope completion)."); // safety check - again, this should never happen as the plan has been validated, // and this is just a paranoid safety test diff --git a/src/Umbraco.Infrastructure/PublishedCache/PublishedContentTypeCache.cs b/src/Umbraco.Infrastructure/PublishedCache/PublishedContentTypeCache.cs index 1e798da3b2..c6196aeca8 100644 --- a/src/Umbraco.Infrastructure/PublishedCache/PublishedContentTypeCache.cs +++ b/src/Umbraco.Infrastructure/PublishedCache/PublishedContentTypeCache.cs @@ -23,11 +23,11 @@ namespace Umbraco.Web.PublishedCache private readonly IMediaTypeService _mediaTypeService; private readonly IMemberTypeService _memberTypeService; private readonly IPublishedContentTypeFactory _publishedContentTypeFactory; - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(); // default ctor - public PublishedContentTypeCache(IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, IPublishedContentTypeFactory publishedContentTypeFactory, ILogger logger) + public PublishedContentTypeCache(IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, IPublishedContentTypeFactory publishedContentTypeFactory, ILogger logger) { _contentTypeService = contentTypeService; _mediaTypeService = mediaTypeService; @@ -37,7 +37,7 @@ namespace Umbraco.Web.PublishedCache } // for unit tests ONLY - internal PublishedContentTypeCache(ILogger logger, IPublishedContentTypeFactory publishedContentTypeFactory) + internal PublishedContentTypeCache(ILogger logger, IPublishedContentTypeFactory publishedContentTypeFactory) { _logger = logger; _publishedContentTypeFactory = publishedContentTypeFactory; @@ -50,7 +50,7 @@ namespace Umbraco.Web.PublishedCache ///
public void ClearAll() { - _logger.Debug("Clear all."); + _logger.LogDebug("Clear all."); try { @@ -72,7 +72,7 @@ namespace Umbraco.Web.PublishedCache /// An identifier. public void ClearContentType(int id) { - _logger.Debug("Clear content type w/id {ContentTypeId}", id); + _logger.LogDebug("Clear content type w/id {ContentTypeId}", id); try { @@ -107,7 +107,7 @@ namespace Umbraco.Web.PublishedCache /// A data type identifier. public void ClearDataType(int id) { - _logger.Debug("Clear data type w/id {DataTypeId}.", id); + _logger.LogDebug("Clear data type w/id {DataTypeId}.", id); // there is no recursion to handle here because a PublishedContentType contains *all* its // properties ie both its own properties and those that were inherited (it's based upon an diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs index 08f0d8d378..eef0cc379a 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs @@ -128,7 +128,7 @@ namespace Umbraco.Core.Runtime "Boot failed.")) { - Logger.Info("Booting site '{HostingSiteName}', app '{HostingApplicationId}', path '{HostingPhysicalPath}', server '{MachineName}'.", + Logger.LogInformation("Booting site '{HostingSiteName}', app '{HostingApplicationId}', path '{HostingPhysicalPath}', server '{MachineName}'.", HostingEnvironment?.SiteName, HostingEnvironment?.ApplicationId, HostingEnvironment?.ApplicationPhysicalPath, diff --git a/src/Umbraco.Infrastructure/Scheduling/BackgroundTaskRunner.cs b/src/Umbraco.Infrastructure/Scheduling/BackgroundTaskRunner.cs index 9aac31a562..ae753883fc 100644 --- a/src/Umbraco.Infrastructure/Scheduling/BackgroundTaskRunner.cs +++ b/src/Umbraco.Infrastructure/Scheduling/BackgroundTaskRunner.cs @@ -348,7 +348,7 @@ namespace Umbraco.Web.Scheduling var hasTasks = TaskCount > 0; if (!force && hasTasks) - _logger.Info("{LogPrefix} Waiting for tasks to complete", _logPrefix); + _logger.LogInformation("{LogPrefix} Waiting for tasks to complete", _logPrefix); // complete the queue // will stop waiting on the queue or on a latch @@ -704,7 +704,7 @@ namespace Umbraco.Web.Scheduling if (_terminating == false) { _terminating = true; - _logger.Info("{LogPrefix} Terminating {Immediate}", _logPrefix, immediate ? immediate.ToString() : string.Empty); + _logger.LogInformation("{LogPrefix} Terminating {Immediate}", _logPrefix, immediate ? immediate.ToString() : string.Empty); onTerminating = true; } } @@ -789,7 +789,7 @@ namespace Umbraco.Web.Scheduling /// private void StopImmediate() { - _logger.Info("{LogPrefix} Canceling tasks", _logPrefix); + _logger.LogInformation("{LogPrefix} Canceling tasks", _logPrefix); try { Shutdown(true, true); // cancel all tasks, wait for the current one to end @@ -823,7 +823,7 @@ namespace Umbraco.Web.Scheduling terminatedSource = _terminatedSource; } - _logger.Info("{LogPrefix} Tasks {TaskStatus}, terminated", + _logger.LogInformation("{LogPrefix} Tasks {TaskStatus}, terminated", _logPrefix, immediate ? "cancelled" : "completed"); diff --git a/src/Umbraco.Infrastructure/Scheduling/ScheduledPublishing.cs b/src/Umbraco.Infrastructure/Scheduling/ScheduledPublishing.cs index e5c35a32aa..8d8015f449 100644 --- a/src/Umbraco.Infrastructure/Scheduling/ScheduledPublishing.cs +++ b/src/Umbraco.Infrastructure/Scheduling/ScheduledPublishing.cs @@ -83,7 +83,7 @@ namespace Umbraco.Web.Scheduling // run var result = _contentService.PerformScheduledPublish(DateTime.Now); foreach (var grouped in result.GroupBy(x => x.Result)) - _logger.Info( + _logger.LogInformation( "Scheduled publishing result: '{StatusCount}' items with status {Status}", grouped.Count(), grouped.Key); } diff --git a/src/Umbraco.Infrastructure/Search/BackgroundIndexRebuilder.cs b/src/Umbraco.Infrastructure/Search/BackgroundIndexRebuilder.cs index deea247c4b..0ecef1f253 100644 --- a/src/Umbraco.Infrastructure/Search/BackgroundIndexRebuilder.cs +++ b/src/Umbraco.Infrastructure/Search/BackgroundIndexRebuilder.cs @@ -46,7 +46,7 @@ namespace Umbraco.Web.Search return; } - _logger.Info("Starting initialize async background thread."); + _logger.LogInformation("Starting initialize async background thread."); //do the rebuild on a managed background thread var task = new RebuildOnStartupTask(_mainDom, _indexRebuilder, _logger, onlyEmptyIndexes, waitMilliseconds); diff --git a/src/Umbraco.Infrastructure/Search/ExamineComponent.cs b/src/Umbraco.Infrastructure/Search/ExamineComponent.cs index ae5bfd628b..ab1c20b0a3 100644 --- a/src/Umbraco.Infrastructure/Search/ExamineComponent.cs +++ b/src/Umbraco.Infrastructure/Search/ExamineComponent.cs @@ -72,7 +72,7 @@ namespace Umbraco.Web.Search if (!examineShutdownRegistered) { - _logger.Info("Examine shutdown not registered, this AppDomain is not the MainDom, Examine will be disabled"); + _logger.LogInformation("Examine shutdown not registered, this AppDomain is not the MainDom, Examine will be disabled"); //if we could not register the shutdown examine ourselves, it means we are not maindom! in this case all of examine should be disabled! Suspendable.ExamineEvents.SuspendIndexers(_logger); @@ -87,7 +87,7 @@ namespace Umbraco.Web.Search var registeredIndexers = _examineManager.Indexes.OfType().Count(x => x.EnableDefaultEventHandler); - _logger.Info("Adding examine event handlers for {RegisteredIndexers} index providers.", registeredIndexers); + _logger.LogInformation("Adding examine event handlers for {RegisteredIndexers} index providers.", registeredIndexers); // don't bind event handlers if we're not suppose to listen if (registeredIndexers == 0) diff --git a/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs b/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs index 6d35196533..266a18f931 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/ContentService.cs @@ -2635,7 +2635,7 @@ namespace Umbraco.Core.Services.Implement // raise Publishing event if (scope.Events.DispatchCancelable(Publishing, this, savingEventArgs.ToContentPublishingEventArgs())) { - Logger.Info("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "publishing was cancelled"); + Logger.LogInformation("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "publishing was cancelled"); return new PublishResult(PublishResultType.FailedPublishCancelledByEvent, evtMsgs, content); } @@ -2687,7 +2687,7 @@ namespace Umbraco.Core.Services.Implement // either because it is 'publishing' or because it already has a published version if (content.PublishedState != PublishedState.Publishing && content.PublishedVersionId == 0) { - Logger.Info("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "document does not have published values"); + Logger.LogInformation("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "document does not have published values"); return new PublishResult(PublishResultType.FailedPublishNothingToPublish, evtMsgs, content); } @@ -2700,20 +2700,20 @@ namespace Umbraco.Core.Services.Implement { case ContentStatus.Expired: if (!variesByCulture) - Logger.Info("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "document has expired"); + Logger.LogInformation("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "document has expired"); else - Logger.Info("Document {ContentName} (id={ContentId}) culture {Culture} cannot be published: {Reason}", content.Name, content.Id, culture, "document culture has expired"); + Logger.LogInformation("Document {ContentName} (id={ContentId}) culture {Culture} cannot be published: {Reason}", content.Name, content.Id, culture, "document culture has expired"); return new PublishResult(!variesByCulture ? PublishResultType.FailedPublishHasExpired : PublishResultType.FailedPublishCultureHasExpired, evtMsgs, content); case ContentStatus.AwaitingRelease: if (!variesByCulture) - Logger.Info("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "document is awaiting release"); + Logger.LogInformation("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "document is awaiting release"); else - Logger.Info("Document {ContentName} (id={ContentId}) culture {Culture} cannot be published: {Reason}", content.Name, content.Id, culture, "document is culture awaiting release"); + Logger.LogInformation("Document {ContentName} (id={ContentId}) culture {Culture} cannot be published: {Reason}", content.Name, content.Id, culture, "document is culture awaiting release"); return new PublishResult(!variesByCulture ? PublishResultType.FailedPublishAwaitingRelease : PublishResultType.FailedPublishCultureAwaitingRelease, evtMsgs, content); case ContentStatus.Trashed: - Logger.Info("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "document is trashed"); + Logger.LogInformation("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "document is trashed"); return new PublishResult(PublishResultType.FailedPublishIsTrashed, evtMsgs, content); } } @@ -2726,7 +2726,7 @@ namespace Umbraco.Core.Services.Implement var pathIsOk = content.ParentId == Constants.System.Root || IsPathPublished(GetParent(content)); if (!pathIsOk) { - Logger.Info("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "parent is not published"); + Logger.LogInformation("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "parent is not published"); return new PublishResult(PublishResultType.FailedPublishPathNotPublished, evtMsgs, content); } } @@ -2763,11 +2763,11 @@ namespace Umbraco.Core.Services.Implement return new PublishResult(PublishResultType.FailedPublishNothingToPublish, evtMsgs, content); if (culturesUnpublishing.Count > 0) - Logger.Info("Document {ContentName} (id={ContentId}) cultures: {Cultures} have been unpublished.", + Logger.LogInformation("Document {ContentName} (id={ContentId}) cultures: {Cultures} have been unpublished.", content.Name, content.Id, string.Join(",", culturesUnpublishing)); if (culturesPublishing.Count > 0) - Logger.Info("Document {ContentName} (id={ContentId}) cultures: {Cultures} have been published.", + Logger.LogInformation("Document {ContentName} (id={ContentId}) cultures: {Cultures} have been published.", content.Name, content.Id, string.Join(",", culturesPublishing)); if (culturesUnpublishing.Count > 0 && culturesPublishing.Count > 0) @@ -2779,7 +2779,7 @@ namespace Umbraco.Core.Services.Implement return new PublishResult(PublishResultType.SuccessPublishCulture, evtMsgs, content); } - Logger.Info("Document {ContentName} (id={ContentId}) has been published.", content.Name, content.Id); + Logger.LogInformation("Document {ContentName} (id={ContentId}) has been published.", content.Name, content.Id); return new PublishResult(evtMsgs, content); } @@ -2795,7 +2795,7 @@ namespace Umbraco.Core.Services.Implement // raise Unpublishing event if (scope.Events.DispatchCancelable(Unpublishing, this, new PublishEventArgs(content, evtMsgs))) { - Logger.Info("Document {ContentName} (id={ContentId}) cannot be unpublished: unpublishing was cancelled.", content.Name, content.Id); + Logger.LogInformation("Document {ContentName} (id={ContentId}) cannot be unpublished: unpublishing was cancelled.", content.Name, content.Id); return new PublishResult(PublishResultType.FailedUnpublishCancelledByEvent, evtMsgs, content); } @@ -2827,12 +2827,12 @@ namespace Umbraco.Core.Services.Implement foreach (var p in pastReleases) content.ContentSchedule.Remove(p); if (pastReleases.Count > 0) - Logger.Info("Document {ContentName} (id={ContentId}) had its release date removed, because it was unpublished.", content.Name, content.Id); + Logger.LogInformation("Document {ContentName} (id={ContentId}) had its release date removed, because it was unpublished.", content.Name, content.Id); // change state to unpublishing content.PublishedState = PublishedState.Unpublishing; - Logger.Info("Document {ContentName} (id={ContentId}) has been unpublished.", content.Name, content.Id); + Logger.LogInformation("Document {ContentName} (id={ContentId}) has been unpublished.", content.Name, content.Id); return attempt; } @@ -3173,7 +3173,7 @@ namespace Umbraco.Core.Services.Implement scope.Events.Dispatch(RolledBack, this, rollbackEventArgs); //Logging & Audit message - Logger.Info("User '{UserId}' rolled back content '{ContentId}' to version '{VersionId}'", userId, id, versionId); + Logger.LogInformation("User '{UserId}' rolled back content '{ContentId}' to version '{VersionId}'", userId, id, versionId); Audit(AuditType.RollBack, userId, id, $"Content '{content.Name}' was rolled back to version '{versionId}'"); } diff --git a/src/Umbraco.Infrastructure/Suspendable.cs b/src/Umbraco.Infrastructure/Suspendable.cs index 75797b5f54..14582dd56a 100644 --- a/src/Umbraco.Infrastructure/Suspendable.cs +++ b/src/Umbraco.Infrastructure/Suspendable.cs @@ -38,7 +38,7 @@ namespace Umbraco.Web { _suspended = false; - Current.Logger.Info("Resume document cache (reload:{Tried}).", _tried); + LoggerExtensions.LogInformation(Current.Logger, "Resume document cache (reload:{Tried}).", _tried); if (_tried == false) return; _tried = false; @@ -74,7 +74,7 @@ namespace Umbraco.Web { _suspended = false; - logger.Info("Resume indexers (rebuild:{Tried}).", _tried); + LoggerExtensions.LogInformation(logger, "Resume indexers (rebuild:{Tried}).", _tried); if (_tried == false) return; _tried = false; diff --git a/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs b/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs index f9556e9408..11da064637 100644 --- a/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs +++ b/src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs @@ -377,7 +377,7 @@ namespace Umbraco.Core.Sync //if they couldn't be all processed (i.e. we're shutting down) then exit if (success == false) { - Logger.Info("The current batch of instructions was not processed, app is shutting down"); + Logger.LogInformation("The current batch of instructions was not processed, app is shutting down"); break; } diff --git a/src/Umbraco.ModelsBuilder.Embedded/LiveModelsProvider.cs b/src/Umbraco.ModelsBuilder.Embedded/LiveModelsProvider.cs index 4f32457417..a7bef79cee 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/LiveModelsProvider.cs +++ b/src/Umbraco.ModelsBuilder.Embedded/LiveModelsProvider.cs @@ -85,10 +85,10 @@ namespace Umbraco.ModelsBuilder.Embedded _logger.Debug("Generate models..."); const int timeout = 2 * 60 * 1000; // 2 mins _mutex.WaitOne(timeout); // wait until it is safe, and acquire - _logger.Info("Generate models now."); + _logger.LogInformation("Generate models now."); GenerateModels(); _mbErrors.Clear(); - _logger.Info("Generated."); + _logger.LogInformation("Generated."); } catch (TimeoutException) { diff --git a/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs b/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs index c138d68ae9..d2f846ae1b 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs +++ b/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs @@ -24,7 +24,8 @@ namespace Umbraco.ModelsBuilder.Embedded private readonly ReaderWriterLockSlim _locker = new ReaderWriterLockSlim(); private volatile bool _hasModels; // volatile 'cos reading outside lock private bool _pendingRebuild; - private readonly IProfilingLogger _logger; + private readonly IProfilingLogger _profilingLogger; + private readonly ILogger _logger; private readonly FileSystemWatcher _watcher; private int _ver, _skipver; private readonly int _debugLevel; @@ -44,13 +45,15 @@ namespace Umbraco.ModelsBuilder.Embedded public PureLiveModelFactory( Lazy umbracoServices, - IProfilingLogger logger, + IProfilingLogger profilingLogger, + ILogger logger, IModelsBuilderConfig config, IHostingEnvironment hostingEnvironment, IApplicationShutdownRegistry hostingLifetime, IPublishedValueFallback publishedValueFallback) { _umbracoServices = umbracoServices; + _profilingLogger = profilingLogger; _logger = logger; _config = config; _hostingEnvironment = hostingEnvironment; @@ -212,7 +215,7 @@ namespace Umbraco.ModelsBuilder.Embedded // tells the factory that it should build a new generation of models private void ResetModels() { - _logger.Debug("Resetting models."); + _logger.LogDebug("Resetting models."); try { @@ -254,7 +257,7 @@ namespace Umbraco.ModelsBuilder.Embedded internal Infos EnsureModels() { if (_debugLevel > 0) - _logger.Debug("Ensuring models."); + _logger.LogDebug("Ensuring models."); // don't use an upgradeable lock here because only 1 thread at a time could enter it try @@ -286,7 +289,7 @@ namespace Umbraco.ModelsBuilder.Embedded // either they haven't been loaded from the cache yet // or they have been reseted and are pending a rebuild - using (_logger.DebugDuration("Get models.", "Got models.")) + using (_profilingLogger.DebugDuration("Get models.", "Got models.")) { try { @@ -305,8 +308,8 @@ namespace Umbraco.ModelsBuilder.Embedded { try { - _logger.LogError("Failed to build models.", e); - _logger.LogWarning("Running without models."); // be explicit + _logger.LogWarning("Failed to build models.", e); + _logger.LogWarning("Running without models."); // be explicit _errors.Report("Failed to build PureLive models.", e); } finally @@ -372,13 +375,13 @@ namespace Umbraco.ModelsBuilder.Embedded if (!forceRebuild) { - _logger.Debug("Looking for cached models."); + _logger.LogDebug("Looking for cached models."); if (File.Exists(modelsHashFile) && File.Exists(projFile)) { var cachedHash = File.ReadAllText(modelsHashFile); if (currentHash != cachedHash) { - _logger.Debug("Found obsolete cached models."); + _logger.LogDebug("Found obsolete cached models."); forceRebuild = true; } @@ -386,7 +389,7 @@ namespace Umbraco.ModelsBuilder.Embedded } else { - _logger.Debug("Could not find cached models."); + _logger.LogDebug("Could not find cached models."); forceRebuild = true; } } @@ -403,7 +406,7 @@ namespace Umbraco.ModelsBuilder.Embedded { var dllPath = File.ReadAllText(dllPathFile); - _logger.Debug($"Cached models dll at {dllPath}."); + _logger.LogDebug($"Cached models dll at {dllPath}."); if (File.Exists(dllPath) && !File.Exists(dllPath + ".delete")) { @@ -418,18 +421,18 @@ namespace Umbraco.ModelsBuilder.Embedded // with the "same but different" version of the assembly in memory _skipver = assembly.GetName().Version.Revision; - _logger.Debug("Loading cached models (dll)."); + _logger.LogDebug("Loading cached models (dll)."); return assembly; } - _logger.Debug("Cached models dll cannot be loaded (invalid assembly)."); + _logger.LogDebug("Cached models dll cannot be loaded (invalid assembly)."); } else if (!File.Exists(dllPath)) - _logger.Debug("Cached models dll does not exist."); + _logger.LogDebug("Cached models dll does not exist."); else if (File.Exists(dllPath + ".delete")) - _logger.Debug("Cached models dll is marked for deletion."); + _logger.LogDebug("Cached models dll is marked for deletion."); else - _logger.Debug("Cached models dll cannot be loaded (why?)."); + _logger.LogDebug("Cached models dll cannot be loaded (why?)."); } // must reset the version in the file else it would keep growing @@ -458,12 +461,12 @@ namespace Umbraco.ModelsBuilder.Embedded throw; } - _logger.Debug("Loading cached models (source)."); + _logger.LogDebug("Loading cached models (source)."); return assembly; } // need to rebuild - _logger.Debug("Rebuilding models."); + _logger.LogDebug("Rebuilding models."); // generate code, save var code = GenerateModelsCode(typeModels); @@ -500,7 +503,7 @@ namespace Umbraco.ModelsBuilder.Embedded throw; } - _logger.Debug("Done rebuilding."); + _logger.LogDebug("Done rebuilding."); return assembly; } @@ -537,7 +540,7 @@ namespace Umbraco.ModelsBuilder.Embedded private void ClearOnFailingToCompile(string dllPathFile, string modelsHashFile, string projFile) { - _logger.Debug("Failed to compile."); + _logger.LogDebug("Failed to compile."); // the dll file reference still points to the previous dll, which is obsolete // now and will be deleted by ASP.NET eventually, so better clear that reference. @@ -704,7 +707,7 @@ namespace Umbraco.ModelsBuilder.Embedded //if (_building && OurFiles.Contains(changed)) //{ - // //_logger.Info("Ignoring files self-changes."); + // //_logger.LogInformation("Ignoring files self-changes."); // return; //} @@ -712,7 +715,7 @@ namespace Umbraco.ModelsBuilder.Embedded if (OurFiles.Contains(changed)) return; - _logger.Info("Detected files changes."); + _logger.LogInformation("Detected files changes."); lock (SyncRoot) // don't reset while being locked ResetModels(); diff --git a/src/Umbraco.PublishedCache.NuCache/ContentStore.cs b/src/Umbraco.PublishedCache.NuCache/ContentStore.cs index 4dceb6f550..c9c6ad49d0 100644 --- a/src/Umbraco.PublishedCache.NuCache/ContentStore.cs +++ b/src/Umbraco.PublishedCache.NuCache/ContentStore.cs @@ -46,7 +46,8 @@ namespace Umbraco.Web.PublishedCache.NuCache private readonly ConcurrentDictionary _contentTypeKeyToIdMap; private readonly ConcurrentDictionary _contentKeyToIdMap; - private readonly ILogger _logger; + private readonly ILogger _logger; + private readonly ILogger _snapShotLogger; private readonly IPublishedModelFactory _publishedModelFactory; private BPlusTree _localDb; private readonly ConcurrentQueue _genObjs; @@ -67,13 +68,15 @@ namespace Umbraco.Web.PublishedCache.NuCache public ContentStore( IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, - ILogger logger, + ILogger logger, + ILogger snapShotLogger, IPublishedModelFactory publishedModelFactory, BPlusTree localDb = null) { _publishedSnapshotAccessor = publishedSnapshotAccessor; _variationContextAccessor = variationContextAccessor; _logger = logger; + _snapShotLogger = snapShotLogger; _publishedModelFactory = publishedModelFactory; _localDb = localDb; @@ -253,7 +256,7 @@ namespace Umbraco.Web.PublishedCache.NuCache catch (Exception ex) { /* TBD: May already be throwing so don't throw again */ - _logger.LogError(ex, "Error trying to release DB"); + _logger.LogError(ex, "Error trying to release DB"); } finally { @@ -264,7 +267,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } catch (Exception ex) { - _logger.LogError(ex, "Error trying to lock"); + _logger.LogError(ex, "Error trying to lock"); throw; } finally @@ -521,7 +524,7 @@ namespace Umbraco.Web.PublishedCache.NuCache parent = GetParentLink(kit.Node, null); if (parent == null) { - _logger.LogWarning($"Skip item id={kit.Node.Id}, could not find parent id={kit.Node.ParentContentId}."); + _logger.LogWarning($"Skip item id={kit.Node.Id}, could not find parent id={kit.Node.ParentContentId}."); return false; } @@ -530,21 +533,21 @@ namespace Umbraco.Web.PublishedCache.NuCache // because the data sort operation is by path. if (parent.Value == null) { - _logger.LogWarning($"Skip item id={kit.Node.Id}, no Data assigned for linked node with path {kit.Node.Path} and parent id {kit.Node.ParentContentId}. This can indicate data corruption for the Path value for node {kit.Node.Id}. See the Health Check dashboard in Settings to resolve data integrity issues."); + _logger.LogWarning($"Skip item id={kit.Node.Id}, no Data assigned for linked node with path {kit.Node.Path} and parent id {kit.Node.ParentContentId}. This can indicate data corruption for the Path value for node {kit.Node.Id}. See the Health Check dashboard in Settings to resolve data integrity issues."); return false; } // make sure the kit is valid if (kit.DraftData == null && kit.PublishedData == null) { - _logger.LogWarning($"Skip item id={kit.Node.Id}, both draft and published data are null."); + _logger.LogWarning($"Skip item id={kit.Node.Id}, both draft and published data are null."); return false; } // unknown = bad if (_contentTypesById.TryGetValue(kit.ContentTypeId, out var link) == false || link.Value == null) { - _logger.LogWarning($"Skip item id={kit.Node.Id}, could not find content type id={kit.ContentTypeId}."); + _logger.LogWarning($"Skip item id={kit.Node.Id}, could not find content type id={kit.ContentTypeId}."); return false; } @@ -601,7 +604,7 @@ namespace Umbraco.Web.PublishedCache.NuCache throw new ArgumentException("Kit content cannot have children.", nameof(kit)); // ReSharper restore LocalizableElement - _logger.Debug("Set content ID: {KitNodeId}", kit.Node.Id); + _logger.LogDebug("Set content ID: {KitNodeId}", kit.Node.Id); // get existing _contentNodes.TryGetValue(kit.Node.Id, out var link); @@ -720,7 +723,7 @@ namespace Umbraco.Web.PublishedCache.NuCache previousNode = null; // there is no previous sibling } - _logger.Debug($"Set {thisNode.Id} with parent {thisNode.ParentContentId}"); + _logger.LogDebug($"Set {thisNode.Id} with parent {thisNode.ParentContentId}"); SetValueLocked(_contentNodes, thisNode.Id, thisNode); // if we are initializing from the database source ensure the local db is updated @@ -777,7 +780,7 @@ namespace Umbraco.Web.PublishedCache.NuCache ok = false; continue; // skip that one } - _logger.Debug($"Set {kit.Node.Id} with parent {kit.Node.ParentContentId}"); + _logger.LogDebug($"Set {kit.Node.Id} with parent {kit.Node.ParentContentId}"); SetValueLocked(_contentNodes, kit.Node.Id, kit.Node); if (_localDb != null) RegisterChange(kit.Node.Id, kit); @@ -866,7 +869,7 @@ namespace Umbraco.Web.PublishedCache.NuCache if (link?.Value == null) return false; var content = link.Value; - _logger.Debug("Clear content ID: {ContentId}", content.Id); + _logger.LogDebug("Clear content ID: {ContentId}", content.Id); // clear the entire branch ClearBranchLocked(content); @@ -1308,7 +1311,7 @@ namespace Umbraco.Web.PublishedCache.NuCache if (_nextGen == false && _genObj != null) return new Snapshot(this, _genObj.GetGenRef() #if DEBUG - , _logger + , _snapShotLogger #endif ); @@ -1344,7 +1347,7 @@ namespace Umbraco.Web.PublishedCache.NuCache var snapshot = new Snapshot(this, _genObj.GetGenRef() #if DEBUG - , _logger + , _snapShotLogger #endif ); @@ -1358,7 +1361,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public Snapshot LiveSnapshot => new Snapshot(this, _liveGen #if DEBUG - , _logger + , _snapShotLogger #endif ); @@ -1393,14 +1396,14 @@ namespace Umbraco.Web.PublishedCache.NuCache { // see notes in CreateSnapshot #if DEBUG - _logger.Debug("Collect."); + _logger.LogDebug("Collect."); #endif while (_genObjs.TryPeek(out var genObj) && (genObj.Count == 0 || genObj.WeakGenRef.IsAlive == false)) { _genObjs.TryDequeue(out genObj); // cannot fail since TryPeek has succeeded _floorGen = genObj.Gen; #if DEBUG - //_logger.Debug("_floorGen=" + _floorGen + ", _liveGen=" + _liveGen); + //_logger.LogDebug("_floorGen=" + _floorGen + ", _liveGen=" + _liveGen); #endif } @@ -1438,7 +1441,7 @@ namespace Umbraco.Web.PublishedCache.NuCache var link = kvp.Value; #if DEBUG - //_logger.Debug("Collect id:" + kvp.Key + ", gen:" + link.Gen + + //_logger.LogDebug("Collect id:" + kvp.Key + ", gen:" + link.Gen + // ", nxt:" + (link.Next == null ? "null" : "link") + // ", val:" + (link.Value == null ? "null" : "value")); #endif @@ -1546,7 +1549,7 @@ namespace Umbraco.Web.PublishedCache.NuCache private readonly GenRef _genRef; private long _gen; #if DEBUG - private readonly ILogger _logger; + private readonly ILogger _logger; #endif //private static int _count; @@ -1554,7 +1557,7 @@ namespace Umbraco.Web.PublishedCache.NuCache internal Snapshot(ContentStore store, GenRef genRef #if DEBUG - , ILogger logger + , ILogger logger #endif ) { @@ -1566,13 +1569,13 @@ namespace Umbraco.Web.PublishedCache.NuCache #if DEBUG _logger = logger; - _logger.Debug("Creating snapshot."); + _logger.LogDebug("Creating snapshot."); #endif } internal Snapshot(ContentStore store, long gen #if DEBUG - , ILogger logger + , ILogger logger #endif ) { @@ -1581,7 +1584,7 @@ namespace Umbraco.Web.PublishedCache.NuCache #if DEBUG _logger = logger; - _logger.Debug("Creating live."); + _logger.LogDebug("Creating live."); #endif } @@ -1669,7 +1672,7 @@ namespace Umbraco.Web.PublishedCache.NuCache { if (_gen < 0) return; #if DEBUG - _logger.Debug("Dispose snapshot ({Snapshot})", _genRef?.GenObj.Count.ToString() ?? "live"); + _logger.LogDebug("Dispose snapshot ({Snapshot})", _genRef?.GenObj.Count.ToString() ?? "live"); #endif _gen = -1; if (_genRef != null) diff --git a/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs index 7d41243098..3ade8eb34a 100644 --- a/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs @@ -39,9 +39,11 @@ namespace Umbraco.Web.PublishedCache.NuCache { private readonly ServiceContext _serviceContext; private readonly IPublishedContentTypeFactory _publishedContentTypeFactory; + private readonly IProfilingLogger _profilingLogger; private readonly IScopeProvider _scopeProvider; private readonly IDataSource _dataSource; - private readonly IProfilingLogger _logger; + private readonly ILogger _logger; + private readonly ILogger _publishedContentTypeCacheLogger; private readonly IDocumentRepository _documentRepository; private readonly IMediaRepository _mediaRepository; private readonly IMemberRepository _memberRepository; @@ -81,7 +83,9 @@ namespace Umbraco.Web.PublishedCache.NuCache public PublishedSnapshotService(PublishedSnapshotServiceOptions options, IMainDom mainDom, IRuntimeState runtime, ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, - IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, IProfilingLogger logger, IScopeProvider scopeProvider, + IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, + IProfilingLogger profilingLogger, ILogger logger, ILogger contentLogger, ILogger snapshotLogger, ILogger publishedContentTypeCacheLogger, + IScopeProvider scopeProvider, IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository, IDefaultCultureAccessor defaultCultureAccessor, IDataSource dataSource, IGlobalSettings globalSettings, @@ -99,8 +103,10 @@ namespace Umbraco.Web.PublishedCache.NuCache _serviceContext = serviceContext; _publishedContentTypeFactory = publishedContentTypeFactory; + _profilingLogger = profilingLogger; _dataSource = dataSource; _logger = logger; + _publishedContentTypeCacheLogger = publishedContentTypeCacheLogger; _scopeProvider = scopeProvider; _documentRepository = documentRepository; _mediaRepository = mediaRepository; @@ -144,18 +150,18 @@ namespace Umbraco.Web.PublishedCache.NuCache // stores are created with a db so they can write to it, but they do not read from it, // stores need to be populated, happens in OnResolutionFrozen which uses _localDbExists to // figure out whether it can read the databases or it should populate them from sql - - _logger.Info("Creating the content store, localContentDbExists? {LocalContentDbExists}", _localContentDbExists); - _contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, publishedModelFactory, _localContentDb); - _logger.Info("Creating the media store, localMediaDbExists? {LocalMediaDbExists}", _localMediaDbExists); - _mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, publishedModelFactory, _localMediaDb); + + _logger.LogInformation("Creating the content store, localContentDbExists? {LocalContentDbExists}", _localContentDbExists); + _contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, contentLogger, snapshotLogger, publishedModelFactory, _localContentDb); + _logger.LogInformation("Creating the media store, localMediaDbExists? {LocalMediaDbExists}", _localMediaDbExists); + _mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, contentLogger, snapshotLogger, publishedModelFactory, _localMediaDb); } else { - _logger.Info("Creating the content store (local db ignored)"); - _contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, publishedModelFactory); - _logger.Info("Creating the media store (local db ignored)"); - _mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, logger, publishedModelFactory); + _logger.LogInformation("Creating the content store (local db ignored)"); + _contentStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, contentLogger, snapshotLogger, publishedModelFactory); + _logger.LogInformation("Creating the media store (local db ignored)"); + _mediaStore = new ContentStore(publishedSnapshotAccessor, variationContextAccessor, contentLogger, snapshotLogger, publishedModelFactory); } _domainStore = new SnapDictionary(); @@ -201,7 +207,7 @@ namespace Umbraco.Web.PublishedCache.NuCache _localContentDb = BTree.GetTree(localContentDbPath, _localContentDbExists, _config); _localMediaDb = BTree.GetTree(localMediaDbPath, _localMediaDbExists, _config); - _logger.Info("Registered with MainDom, localContentDbExists? {LocalContentDbExists}, localMediaDbExists? {LocalMediaDbExists}", _localContentDbExists, _localMediaDbExists); + _logger.LogInformation("Registered with MainDom, localContentDbExists? {LocalContentDbExists}, localMediaDbExists? {LocalMediaDbExists}", _localContentDbExists, _localMediaDbExists); } /// @@ -212,19 +218,19 @@ namespace Umbraco.Web.PublishedCache.NuCache /// private void MainDomRelease() { - _logger.Debug("Releasing from MainDom..."); + _logger.LogDebug("Releasing from MainDom..."); lock (_storesLock) { - _logger.Debug("Releasing content store..."); + _logger.LogDebug("Releasing content store..."); _contentStore?.ReleaseLocalDb(); //null check because we could shut down before being assigned _localContentDb = null; - _logger.Debug("Releasing media store..."); + _logger.LogDebug("Releasing media store..."); _mediaStore?.ReleaseLocalDb(); //null check because we could shut down before being assigned _localMediaDb = null; - _logger.Info("Released from MainDom"); + _logger.LogInformation("Released from MainDom"); } } @@ -243,14 +249,14 @@ namespace Umbraco.Web.PublishedCache.NuCache { okContent = LockAndLoadContent(scope => LoadContentFromLocalDbLocked(true)); if (!okContent) - _logger.LogWarning("Loading content from local db raised warnings, will reload from database."); + _logger.LogWarning("Loading content from local db raised warnings, will reload from database."); } if (_localMediaDbExists) { okMedia = LockAndLoadMedia(scope => LoadMediaFromLocalDbLocked(true)); if (!okMedia) - _logger.LogWarning("Loading media from local db raised warnings, will reload from database."); + _logger.LogWarning("Loading media from local db raised warnings, will reload from database."); } if (!okContent) @@ -263,7 +269,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } catch (Exception ex) { - _logger.Fatal(ex, "Panic, exception while loading cache data."); + _logger.LogCritical(ex, "Panic, exception while loading cache data."); throw; } @@ -406,7 +412,7 @@ namespace Umbraco.Web.PublishedCache.NuCache _contentStore.SetAllContentTypesLocked(contentTypes); - using (_logger.TraceDuration("Loading content from database")) + using (_profilingLogger.TraceDuration("Loading content from database")) { // beware! at that point the cache is inconsistent, // assuming we are going to SetAll content items! @@ -425,7 +431,7 @@ namespace Umbraco.Web.PublishedCache.NuCache .Select(x => _publishedContentTypeFactory.CreateContentType(x)); _contentStore.SetAllContentTypesLocked(contentTypes); - using (_logger.TraceDuration("Loading content from local cache file")) + using (_profilingLogger.TraceDuration("Loading content from local cache file")) { // beware! at that point the cache is inconsistent, // assuming we are going to SetAll content items! @@ -477,14 +483,14 @@ namespace Umbraco.Web.PublishedCache.NuCache .Select(x => _publishedContentTypeFactory.CreateContentType(x)); _mediaStore.SetAllContentTypesLocked(mediaTypes); - using (_logger.TraceDuration("Loading media from database")) + using (_profilingLogger.TraceDuration("Loading media from database")) { // beware! at that point the cache is inconsistent, // assuming we are going to SetAll content items! _localMediaDb?.Clear(); - _logger.Debug("Loading media from database..."); + _logger.LogDebug("Loading media from database..."); // IMPORTANT GetAllMediaSources sorts kits by level + parentId + sortOrder var kits = _dataSource.GetAllMediaSources(scope); return onStartup ? _mediaStore.SetAllFastSortedLocked(kits, true) : _mediaStore.SetAllLocked(kits); @@ -497,7 +503,7 @@ namespace Umbraco.Web.PublishedCache.NuCache .Select(x => _publishedContentTypeFactory.CreateContentType(x)); _mediaStore.SetAllContentTypesLocked(mediaTypes); - using (_logger.TraceDuration("Loading media from local cache file")) + using (_profilingLogger.TraceDuration("Loading media from local cache file")) { // beware! at that point the cache is inconsistent, // assuming we are going to SetAll content items! @@ -532,7 +538,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // Update: We will still return false here even though the above mentioned race condition has been fixed since we now // lock the entire operation of creating/populating the cache file with the same lock as releasing/closing the cache file - _logger.Info($"Tried to load {entityType} from the local cache file but it was empty."); + _logger.LogInformation($"Tried to load {entityType} from the local cache file but it was empty."); return false; } @@ -709,7 +715,7 @@ namespace Umbraco.Web.PublishedCache.NuCache foreach (var payload in payloads) { - _logger.Debug("Notified {ChangeTypes} for content {ContentId}", payload.ChangeTypes, payload.Id); + _logger.LogDebug("Notified {ChangeTypes} for content {ContentId}", payload.ChangeTypes, payload.Id); if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll)) { @@ -802,7 +808,7 @@ namespace Umbraco.Web.PublishedCache.NuCache foreach (var payload in payloads) { - _logger.Debug("Notified {ChangeTypes} for media {MediaId}", payload.ChangeTypes, payload.Id); + _logger.LogDebug("Notified {ChangeTypes} for media {MediaId}", payload.ChangeTypes, payload.Id); if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll)) { @@ -873,7 +879,7 @@ namespace Umbraco.Web.PublishedCache.NuCache return; foreach (var payload in payloads) - _logger.Debug("Notified {ChangeTypes} for {ItemType} {ItemId}", payload.ChangeTypes, payload.ItemType, payload.Id); + _logger.LogDebug("Notified {ChangeTypes} for {ItemType} {ItemId}", payload.ChangeTypes, payload.ItemType, payload.Id); Notify(_contentStore, payloads, RefreshContentTypesLocked); Notify(_mediaStore, payloads, RefreshMediaTypesLocked); @@ -957,7 +963,7 @@ namespace Umbraco.Web.PublishedCache.NuCache var idsA = payloads.Select(x => x.Id).ToArray(); foreach (var payload in payloads) - _logger.Debug("Notified {RemovedStatus} for data type {DataTypeId}", + _logger.LogDebug("Notified {RemovedStatus} for data type {DataTypeId}", payload.Removed ? "Removed" : "Refreshed", payload.Id); @@ -1229,7 +1235,7 @@ namespace Umbraco.Web.PublishedCache.NuCache var snapshotCache = new DictionaryAppCache(); - var memberTypeCache = new PublishedContentTypeCache(null, null, _serviceContext.MemberTypeService, _publishedContentTypeFactory, _logger); + var memberTypeCache = new PublishedContentTypeCache(null, null, _serviceContext.MemberTypeService, _publishedContentTypeFactory, _publishedContentTypeCacheLogger); var defaultCulture = _defaultCultureAccessor.DefaultCulture; var domainCache = new DomainCache(domainSnap, defaultCulture); @@ -1490,7 +1496,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public override void Rebuild() { - _logger.Debug("Rebuilding..."); + _logger.LogDebug("Rebuilding..."); using (var scope = _scopeProvider.CreateScope(repositoryCacheMode: RepositoryCacheMode.Scoped)) { scope.ReadLock(Constants.Locks.ContentTree); diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStore.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStore.cs index b21ef866ff..1215f2d489 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStore.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStore.cs @@ -674,7 +674,7 @@ AND (umbracoNode.id=@id)"; // (no need to test _released) internal void SaveXmlToFile() { - Current.Logger.Info("Save Xml to file..."); + Current.Logger.LogInformation("Save Xml to file..."); try { @@ -698,7 +698,7 @@ AND (umbracoNode.id=@id)"; fs.Write(bytes, 0, bytes.Length); } - Current.Logger.Info("Saved Xml to file."); + Current.Logger.LogInformation("Saved Xml to file."); } catch (Exception ex) { @@ -714,7 +714,7 @@ AND (umbracoNode.id=@id)"; // (no need to test _released) internal async Task SaveXmlToFileAsync() { - Current.Logger.Info("Save Xml to file..."); + Current.Logger.LogInformation("Save Xml to file..."); try { @@ -738,7 +738,7 @@ AND (umbracoNode.id=@id)"; await fs.WriteAsync(bytes, 0, bytes.Length); } - Current.Logger.Info("Saved Xml to file."); + Current.Logger.LogInformation("Saved Xml to file."); } catch (Exception ex) { @@ -782,7 +782,7 @@ AND (umbracoNode.id=@id)"; // do NOT try to load if we are not the main domain anymore if (_released) return null; - Current.Logger.Info("Load Xml from file..."); + Current.Logger.LogInformation("Load Xml from file..."); try { @@ -792,7 +792,7 @@ AND (umbracoNode.id=@id)"; xml.Load(fs); } _lastFileRead = DateTime.UtcNow; - Current.Logger.Info("Loaded Xml from file."); + Current.Logger.LogInformation("Loaded Xml from file."); return xml; } catch (FileNotFoundException) diff --git a/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs b/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs index a47e327e20..20c32f2f6f 100644 --- a/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs +++ b/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs @@ -128,7 +128,7 @@ namespace Umbraco.Tests.Services total.AddRange(ServiceContext.ContentService.GetPagedDescendants(content.Id, 0, int.MaxValue, out var _)); } TestProfiler.Disable(); - Current.Logger.Info("Returned {Total} items", total.Count); + Current.Logger.LogInformation("Returned {Total} items", total.Count); } } diff --git a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs index d8197f71ce..e670f95d6a 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs @@ -148,7 +148,7 @@ namespace Umbraco.Web.BackOffice.Controllers //NOTE: We are using 30 seconds because that is what is coded into angular to force logout to give some headway in // the timeout process. - _logger.Info( + _logger.LogInformation( "User logged will be logged out due to timeout: {Username}, IP Address: {IPAddress}", backOfficeIdentity.Name, _ipResolver.GetCurrentRequestIpAddress()); @@ -351,7 +351,7 @@ namespace Umbraco.Web.BackOffice.Controllers var lockedOut = await _userManager.IsLockedOutAsync(identityUser); if (lockedOut) { - _logger.Info("User {UserId} is currently locked out, unlocking and resetting AccessFailedCount", model.UserId); + _logger.LogInformation("User {UserId} is currently locked out, unlocking and resetting AccessFailedCount", model.UserId); //// var user = await UserManager.FindByIdAsync(model.UserId); var unlockResult = await _userManager.SetLockoutEndDateAsync(identityUser, DateTimeOffset.Now); @@ -409,7 +409,7 @@ namespace Umbraco.Web.BackOffice.Controllers { HttpContext.SignOutAsync(Core.Constants.Security.BackOfficeAuthenticationType); - _logger.Info("User {UserName} from IP address {RemoteIpAddress} has logged out", User.Identity == null ? "UNKNOWN" : User.Identity.Name, HttpContext.Connection.RemoteIpAddress); + _logger.LogInformation("User {UserName} from IP address {RemoteIpAddress} has logged out", User.Identity == null ? "UNKNOWN" : User.Identity.Name, HttpContext.Connection.RemoteIpAddress); _userManager.RaiseLogoutSuccessEvent(User, int.Parse(User.Identity.GetUserId())); diff --git a/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs b/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs index f2724dacbb..e8646f4d47 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs @@ -136,7 +136,7 @@ namespace Umbraco.Web.BackOffice.Controllers if (!validate.IsSuccessStatusCode()) throw new HttpResponseException(validate); - _logger.Info("Rebuilding index '{IndexName}'", indexName); + _logger.LogInformation("Rebuilding index '{IndexName}'", indexName); //remove it in case there's a handler there already index.IndexOperationComplete -= Indexer_IndexOperationComplete; @@ -250,9 +250,7 @@ namespace Umbraco.Web.BackOffice.Controllers //ensure it's not listening anymore indexer.IndexOperationComplete -= Indexer_IndexOperationComplete; - _logger - .Info($"Rebuilding index '{indexer.Name}' done."); + _logger.LogInformation($"Rebuilding index '{indexer.Name}' done."); var cacheKey = "temp_indexing_op_" + indexer.Name; _runtimeCache.Clear(cacheKey); diff --git a/src/Umbraco.Web.Common/Profiler/WebProfilerComponent.cs b/src/Umbraco.Web.Common/Profiler/WebProfilerComponent.cs index dfd13ff101..4612b2845c 100644 --- a/src/Umbraco.Web.Common/Profiler/WebProfilerComponent.cs +++ b/src/Umbraco.Web.Common/Profiler/WebProfilerComponent.cs @@ -31,7 +31,7 @@ namespace Umbraco.Web.Common.Profiler // if VoidProfiler was registered, let it be known if (profiler is VoidProfiler) - logger.Info( + logger.LogInformation( "Profiler is VoidProfiler, not profiling (must run debug mode to profile)."); _profile = false; } diff --git a/src/Umbraco.Web/AspNet/AspNetBackOfficeInfo.cs b/src/Umbraco.Web/AspNet/AspNetBackOfficeInfo.cs index 1e60fedeea..d72c64ebf9 100644 --- a/src/Umbraco.Web/AspNet/AspNetBackOfficeInfo.cs +++ b/src/Umbraco.Web/AspNet/AspNetBackOfficeInfo.cs @@ -31,7 +31,7 @@ namespace Umbraco.Web if (url.IsNullOrWhiteSpace() == false) { var umbracoApplicationUrl = url.TrimEnd('/'); - _logger.Info("ApplicationUrl: {UmbracoAppUrl} (using web.routing/@umbracoApplicationUrl)", umbracoApplicationUrl); + _logger.LogInformation("ApplicationUrl: {UmbracoAppUrl} (using web.routing/@umbracoApplicationUrl)", umbracoApplicationUrl); return umbracoApplicationUrl; } diff --git a/src/Umbraco.Web/CdfLogger.cs b/src/Umbraco.Web/CdfLogger.cs index 5c329d89c9..07d4eca0ea 100644 --- a/src/Umbraco.Web/CdfLogger.cs +++ b/src/Umbraco.Web/CdfLogger.cs @@ -26,7 +26,7 @@ namespace Umbraco.Web public void Info(string msg) { - _logger.Info(msg); + _logger.LogInformation(msg); } public void Warn(string msg) diff --git a/src/Umbraco.Web/Logging/OwinLogger.cs b/src/Umbraco.Web/Logging/OwinLogger.cs index a9533c0124..afa4b42cab 100644 --- a/src/Umbraco.Web/Logging/OwinLogger.cs +++ b/src/Umbraco.Web/Logging/OwinLogger.cs @@ -36,25 +36,25 @@ namespace Umbraco.Web.Logging _logger.LogWarning("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); return true; case TraceEventType.Information: - _logger.Info("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); + _logger.LogInformation("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); return true; case TraceEventType.Verbose: - _logger.Debug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); + _logger.LogDebug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); return true; case TraceEventType.Start: - _logger.Debug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); + _logger.LogDebug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); return true; case TraceEventType.Stop: - _logger.Debug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); + _logger.LogDebug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); return true; case TraceEventType.Suspend: - _logger.Debug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); + _logger.LogDebug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); return true; case TraceEventType.Resume: - _logger.Debug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); + _logger.LogDebug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); return true; case TraceEventType.Transfer: - _logger.Debug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); + _logger.LogDebug("[{EventType}] Event Id: {EventId}, State: {State}", eventType, eventId, state); return true; default: throw new ArgumentOutOfRangeException("eventType"); diff --git a/src/Umbraco.Web/Logging/WebProfilerComponent.cs b/src/Umbraco.Web/Logging/WebProfilerComponent.cs index 2edeea6a1b..796d86d16f 100755 --- a/src/Umbraco.Web/Logging/WebProfilerComponent.cs +++ b/src/Umbraco.Web/Logging/WebProfilerComponent.cs @@ -21,7 +21,7 @@ namespace Umbraco.Web.Logging // if VoidProfiler was registered, let it be known if (profiler is VoidProfiler) - logger.Info("Profiler is VoidProfiler, not profiling (must run debug mode to profile)."); + logger.LogInformation("Profiler is VoidProfiler, not profiling (must run debug mode to profile)."); _profile = false; } diff --git a/src/Umbraco.Web/Security/Providers/UmbracoMembershipProvider.cs b/src/Umbraco.Web/Security/Providers/UmbracoMembershipProvider.cs index 95b2dcda58..7c4dff1702 100644 --- a/src/Umbraco.Web/Security/Providers/UmbracoMembershipProvider.cs +++ b/src/Umbraco.Web/Security/Providers/UmbracoMembershipProvider.cs @@ -490,7 +490,7 @@ namespace Umbraco.Web.Security.Providers if (member == null) { - Current.Logger.Info("Login attempt failed for username {Username} from IP address {IpAddress}, the user does not exist", username, _ipResolver.GetCurrentRequestIpAddress()); + Current.Logger.LogInformation("Login attempt failed for username {Username} from IP address {IpAddress}, the user does not exist", username, _ipResolver.GetCurrentRequestIpAddress()); return new ValidateUserResult { @@ -500,7 +500,7 @@ namespace Umbraco.Web.Security.Providers if (member.IsApproved == false) { - Current.Logger.Info("Login attempt failed for username {Username} from IP address {IpAddress}, the user is not approved", username, _ipResolver.GetCurrentRequestIpAddress()); + Current.Logger.LogInformation("Login attempt failed for username {Username} from IP address {IpAddress}, the user is not approved", username, _ipResolver.GetCurrentRequestIpAddress()); return new ValidateUserResult { @@ -510,7 +510,7 @@ namespace Umbraco.Web.Security.Providers } if (member.IsLockedOut) { - Current.Logger.Info("Login attempt failed for username {Username} from IP address {IpAddress}, the user is locked", username, _ipResolver.GetCurrentRequestIpAddress()); + Current.Logger.LogInformation("Login attempt failed for username {Username} from IP address {IpAddress}, the user is locked", username, _ipResolver.GetCurrentRequestIpAddress()); return new ValidateUserResult { @@ -534,11 +534,11 @@ namespace Umbraco.Web.Security.Providers member.IsLockedOut = true; member.LastLockoutDate = DateTime.Now; - Current.Logger.Info("Login attempt failed for username {Username} from IP address {IpAddress}, the user is now locked out, max invalid password attempts exceeded", username, _ipResolver.GetCurrentRequestIpAddress()); + Current.Logger.LogInformation("Login attempt failed for username {Username} from IP address {IpAddress}, the user is now locked out, max invalid password attempts exceeded", username, _ipResolver.GetCurrentRequestIpAddress()); } else { - Current.Logger.Info("Login attempt failed for username {Username} from IP address {IpAddress}", username, _ipResolver.GetCurrentRequestIpAddress()); + Current.Logger.LogInformation("Login attempt failed for username {Username} from IP address {IpAddress}", username, _ipResolver.GetCurrentRequestIpAddress()); } } else @@ -551,7 +551,7 @@ namespace Umbraco.Web.Security.Providers member.LastLoginDate = DateTime.Now; - Current.Logger.Info("Login attempt succeeded for username {Username} from IP address {IpAddress}", username, _ipResolver.GetCurrentRequestIpAddress()); + Current.Logger.LogInformation("Login attempt succeeded for username {Username} from IP address {IpAddress}", username, _ipResolver.GetCurrentRequestIpAddress()); } //don't raise events for this! It just sets the member dates, if we do raise events this will diff --git a/src/Umbraco.Web/UmbracoApplicationBase.cs b/src/Umbraco.Web/UmbracoApplicationBase.cs index 3a68572fa1..86fc7de76c 100644 --- a/src/Umbraco.Web/UmbracoApplicationBase.cs +++ b/src/Umbraco.Web/UmbracoApplicationBase.cs @@ -251,7 +251,7 @@ namespace Umbraco.Web BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null); - Current.Logger.Info("Application shutdown. Details: {ShutdownReason}\r\n\r\n_shutDownMessage={ShutdownMessage}\r\n\r\n_shutDownStack={ShutdownStack}", + Current.Logger.LogInformation("Application shutdown. Details: {ShutdownReason}\r\n\r\n_shutDownMessage={ShutdownMessage}\r\n\r\n_shutDownStack={ShutdownStack}", HostingEnvironment.ShutdownReason, shutDownMessage, shutDownStack); @@ -259,7 +259,7 @@ namespace Umbraco.Web catch (Exception) { //if for some reason that fails, then log the normal output - Current.Logger.Info("Application shutdown. Reason: {ShutdownReason}", HostingEnvironment.ShutdownReason); + Current.Logger.LogInformation("Application shutdown. Reason: {ShutdownReason}", HostingEnvironment.ShutdownReason); } Current.Logger.DisposeIfDisposable(); diff --git a/src/Umbraco.Web/WebAssets/CDF/ClientDependencyConfiguration.cs b/src/Umbraco.Web/WebAssets/CDF/ClientDependencyConfiguration.cs index 59a4f43bec..8532c3ae0d 100644 --- a/src/Umbraco.Web/WebAssets/CDF/ClientDependencyConfiguration.cs +++ b/src/Umbraco.Web/WebAssets/CDF/ClientDependencyConfiguration.cs @@ -85,7 +85,7 @@ namespace Umbraco.Web.WebAssets.CDF versionAttribute.SetValue(newVersion); clientDependencyConfigXml.Save(_fileName, SaveOptions.DisableFormatting); - _logger.Info("Updated version number from {OldVersion} to {NewVersion}", oldVersion, newVersion); + _logger.LogInformation("Updated version number from {OldVersion} to {NewVersion}", oldVersion, newVersion); return true; } }