Skip to content

XmlLoggingConfiguration - AutoReload available by default as before#5782

Merged
snakefoot merged 1 commit intoNLog:devfrom
snakefoot:autoreload
Apr 24, 2025
Merged

XmlLoggingConfiguration - AutoReload available by default as before#5782
snakefoot merged 1 commit intoNLog:devfrom
snakefoot:autoreload

Conversation

@snakefoot
Copy link
Contributor

@snakefoot snakefoot commented Apr 24, 2025

Merged NLog.AutoReloadConfig-project from #5649 back into the NLog-project XmlLoggingConfiguration. Now autoReload="true" will work out of the box just like in previous NLog-versions.

There was little difference in AOT-build-size, and the goal is that XmlLoggingConfiguration has to be explicit loaded.

Now marked LoggingConfiguration.FileNamesToWatch as obsolete, since NLog LogFactory does not have any FileWatcher-capabilities.

@snakefoot snakefoot added this to the 6.0 milestone Apr 24, 2025
@coderabbitai
Copy link

coderabbitai bot commented Apr 24, 2025

Warning

Rate limit exceeded

@snakefoot has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 27 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2904583 and 425f105.

📒 Files selected for processing (12)
  • build.ps1 (0 hunks)
  • run-tests.ps1 (0 hunks)
  • src/NLog.AutoReloadConfig/NLog.AutoReloadConfig.csproj (0 hunks)
  • src/NLog.AutoReloadConfig/README.md (0 hunks)
  • src/NLog.AutoReloadConfig/SetupBuilderAutoReloadExtensions.cs (0 hunks)
  • src/NLog.sln (0 hunks)
  • src/NLog/Config/LoggingConfiguration.cs (2 hunks)
  • src/NLog/Config/XmlLoggingConfiguration.cs (6 hunks)
  • tests/NLog.AutoReloadConfig.Tests/NLog.AutoReloadConfig.Tests.csproj (0 hunks)
  • tests/NLog.UnitTests/Config/AutoReloadTests.cs (9 hunks)
  • tests/NLog.UnitTests/Config/ReloadTests.cs (12 hunks)
  • tests/NLog.UnitTests/ConfigFileLocatorTests.cs (1 hunks)

Walkthrough

This change removes the NLog.AutoReloadConfig extension and its associated test project from the solution, deletes related documentation, and integrates the auto-reload configuration functionality directly into the core XmlLoggingConfiguration class. The new implementation introduces a per-LogFactory watcher mechanism for monitoring configuration file changes and safely reloading configurations with debouncing. The solution file is updated to exclude the removed projects, and the relevant unit test namespace is adjusted to reflect the new structure.

Changes

File(s) Change Summary
src/NLog.AutoReloadConfig/NLog.AutoReloadConfig.csproj
src/NLog.AutoReloadConfig/README.md
src/NLog.AutoReloadConfig/SetupBuilderAutoReloadExtensions.cs
tests/NLog.AutoReloadConfig.Tests/NLog.AutoReloadConfig.Tests.csproj
Deleted the NLog.AutoReloadConfig extension project, its README, extension code for auto-reload monitoring, and its test project.
src/NLog.sln Removed references to NLog.AutoReloadConfig and its test project from the solution file.
src/NLog/Config/XmlLoggingConfiguration.cs Integrated auto-reload monitoring into XmlLoggingConfiguration: added per-LogFactory watcher dictionary, a nested watcher class, debounced reload logic, and updated the AutoReload property and configuration assignment lifecycle.
src/NLog/Config/LoggingConfiguration.cs Marked FileNamesToWatch property as obsolete and hidden from IntelliSense to reflect removal of LogFactory file watcher support.
tests/NLog.UnitTests/Config/AutoReloadTests.cs Changed namespace from NLog.AutoReloadConfig.Tests to NLog.UnitTests.Config; removed calls to the now-removed .SetupMonitorForAutoReload() method; no other logic changes.
tests/NLog.UnitTests/Config/ReloadTests.cs Updated test assertions to use AutoReloadFileNames instead of obsolete FileNamesToWatch; added pragma directives to suppress obsolete warnings where needed.
tests/NLog.UnitTests/ConfigFileLocatorTests.cs Added pragma directives to suppress obsolete warnings around usage of FileNamesToWatch in assertions.
build.ps1 Removed NuGet package creation step for NLog.AutoReloadConfig.
run-tests.ps1 Removed execution and exit code checks for NLog.AutoReloadConfig.Tests test project.

Sequence Diagram(s)

sequenceDiagram
    participant Application
    participant LogFactory
    participant XmlLoggingConfiguration
    participant AutoReloadConfigFileWatcher
    participant FileSystem

    Application->>LogFactory: Assign XmlLoggingConfiguration
    LogFactory->>XmlLoggingConfiguration: OnConfigurationAssigned()
    XmlLoggingConfiguration->>AutoReloadConfigFileWatcher: Create or refresh watcher
    AutoReloadConfigFileWatcher->>FileSystem: Start watching config files

    FileSystem-->>AutoReloadConfigFileWatcher: File change event
    AutoReloadConfigFileWatcher->>AutoReloadConfigFileWatcher: Debounce & schedule reload
    AutoReloadConfigFileWatcher->>XmlLoggingConfiguration: Reload configuration
    XmlLoggingConfiguration->>LogFactory: Activate new configuration (if changed)
Loading

Poem

In the warren of logs where config files dwell,
The watcher now listens where core rabbits excel.
Gone are the extras, the add-ons, the fuss—
Reloading’s now native, streamlined for us!
With each twitch of a file, a new setup appears,
As NLog hops forward through all of our years.
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@snakefoot snakefoot changed the title XmlLoggingConfiguration - AutoReload always available XmlLoggingConfiguration - AutoReload available by default Apr 24, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/NLog/Config/XmlLoggingConfiguration.cs (1)

564-737: Consider replacing the static dictionary with ConditionalWeakTable

Even with the leak fix above, a static cache keyed by LogFactory can grow unbounded in applications that create many transient factories (e.g., in unit tests).
ConditionalWeakTable<LogFactory, AutoReloadConfigFileWatcher> would automatically release entries when the factory becomes unreachable, without explicit bookkeeping.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 64bad89 and f5105f3.

📒 Files selected for processing (7)
  • src/NLog.AutoReloadConfig/NLog.AutoReloadConfig.csproj (0 hunks)
  • src/NLog.AutoReloadConfig/README.md (0 hunks)
  • src/NLog.AutoReloadConfig/SetupBuilderAutoReloadExtensions.cs (0 hunks)
  • src/NLog.sln (0 hunks)
  • src/NLog/Config/XmlLoggingConfiguration.cs (5 hunks)
  • tests/NLog.AutoReloadConfig.Tests/NLog.AutoReloadConfig.Tests.csproj (0 hunks)
  • tests/NLog.UnitTests/Config/AutoReloadTests.cs (1 hunks)
💤 Files with no reviewable changes (5)
  • src/NLog.sln
  • src/NLog.AutoReloadConfig/README.md
  • tests/NLog.AutoReloadConfig.Tests/NLog.AutoReloadConfig.Tests.csproj
  • src/NLog.AutoReloadConfig/NLog.AutoReloadConfig.csproj
  • src/NLog.AutoReloadConfig/SetupBuilderAutoReloadExtensions.cs
🔇 Additional comments (1)
tests/NLog.UnitTests/Config/AutoReloadTests.cs (1)

35-35: Namespace change looks good

The rename to NLog.UnitTests.Config aligns the file with the rest of the unit–test project structure introduced by the merge. No further action needed.

@snakefoot snakefoot force-pushed the autoreload branch 2 times, most recently from 2c9d478 to c62ea33 Compare April 24, 2025 07:57
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (4)
src/NLog/Config/XmlLoggingConfiguration.cs (4)

570-570: ⚠️ Potential issue

Thread-safety: make _isDisposing volatile

_isDisposing is read from multiple threads (timer thread, FileSystemWatcher thread) without a lock. Without the volatile modifier there is no guarantee other threads will observe the write performed in Dispose(), leading to possible use-after-dispose race conditions.

-            private bool _isDisposing;
+            private volatile bool _isDisposing;

576-578: ⚠️ Potential issue

Dead-code / missing subscription for LogFactory.ConfigurationChanged

The AutoReloadConfigFileWatcher class implements LogFactory_ConfigurationChanged, but the constructor never subscribes to the event, and Dispose() never unsubscribes.

Either wire up the event or remove the unused method:

            public AutoReloadConfigFileWatcher(LogFactory logFactory)
            {
                _logFactory = logFactory;
                _fileWatcher.FileChanged += FileWatcher_FileChanged;
+               _logFactory.ConfigurationChanged += LogFactory_ConfigurationChanged;
            }

And in the Dispose method:

            public void Dispose()
            {
                _isDisposing = true;
                _fileWatcher.FileChanged -= FileWatcher_FileChanged;
+               _logFactory.ConfigurationChanged -= LogFactory_ConfigurationChanged;
                lock (_lockObject)
                {
                    var reloadTimer = _reloadTimer;
                    _reloadTimer = null;
                    reloadTimer?.Dispose();
                }
                _fileWatcher.Dispose();
            }

56-56: ⚠️ Potential issue

Potential memory leak in the static _watchers cache

The _watchers dictionary maintains strong references to each LogFactory instance. When a factory is disposed, its watcher is disposed too, but the dictionary entry is never removed. This could prevent both the LogFactory and the AutoReloadConfigFileWatcher instances from being garbage-collected.

Add cleanup code to remove entries when no longer needed:

-        private static readonly Dictionary<LogFactory, AutoReloadConfigFileWatcher> _watchers = new Dictionary<LogFactory, AutoReloadConfigFileWatcher>();
+        private static readonly Dictionary<LogFactory, AutoReloadConfigFileWatcher> _watchers = new Dictionary<LogFactory, AutoReloadConfigFileWatcher>(WeakReferenceComparer.Default);

Or add code to remove entries when the watcher is disposed:

         private void OnConfigurationAssigned(LogFactory logFactory)
         {
             // ...
             if (logFactory is null || !AutoReload)
             {
                 if (fileWatcher != null)
                 {
                     InternalLogger.Info("AutoReload Config File Monitor stopping, since no active configuration");
                     fileWatcher.Dispose();
+                    lock (_watchers)
+                    {
+                        _watchers.Remove(configFactory);
+                    }
                 }
             }
             // ...
         }

220-221: ⚠️ Potential issue

Missing dictionary cleanup when disposing watchers

When the auto-reload feature is disabled or the LogFactory is null, the watcher is disposed but the entry remains in the dictionary. This could lead to a memory leak over time.

                    if (fileWatcher != null)
                    {
                        InternalLogger.Info("AutoReload Config File Monitor stopping, since no active configuration");
                        fileWatcher.Dispose();
+                        lock (_watchers)
+                        {
+                            _watchers.Remove(configFactory);
+                        }
                    }
🧹 Nitpick comments (3)
src/NLog/Config/XmlLoggingConfiguration.cs (3)

610-631: Consider using CancellationTokenSource for better timer management

The current approach of creating and disposing Timer objects could be simplified using a CancellationTokenSource with a delay. This would make the code more maintainable and reduce the chance of resource leaks.

-            private Timer _reloadTimer;
+            private CancellationTokenSource _reloadCts;

             private void FileWatcher_FileChanged(object sender, System.IO.FileSystemEventArgs e)
             {
                 lock (_lockObject)
                 {
                     if (_isDisposing)
                         return;

-                    var reloadTimer = _reloadTimer;
-                    if (reloadTimer is null)
+                    var currentCts = _reloadCts;
+                    if (currentCts != null)
                     {
-                        var currentConfig = _logFactory.Configuration;
-                        if (currentConfig is null)
-                            return;
-
-                        _reloadTimer = new Timer((s) => ReloadTimer(s), currentConfig, 1000, Timeout.Infinite);
+                        currentCts.Cancel();
                     }
-                    else
+                    
+                    var currentConfig = _logFactory.Configuration;
+                    if (currentConfig is null)
+                        return;
+                        
+                    _reloadCts = new CancellationTokenSource();
+                    var token = _reloadCts.Token;
+                    Task.Delay(1000, token).ContinueWith(t => 
                     {
-                        reloadTimer.Change(1000, Timeout.Infinite);
+                        if (!t.IsCanceled)
+                            ReloadTimer(currentConfig);
+                    }, TaskContinuationOptions.NotOnCanceled);
                 }
             }

633-639: Use early return pattern consistently

The early return pattern is used inconsistently. For better readability, consider applying it more uniformly.

         private void ReloadTimer(object state)
         {
             if (_isDisposing)
-            {
-                return; //timer was disposed already.
-            }
+                return; //timer was disposed already.
 
             LoggingConfiguration oldConfig = (LoggingConfiguration)state;

716-718: Release all resources in Dispose method

Ensure all resources are properly released in the Dispose method, including any event subscriptions that might have been set up.

            public void Dispose()
            {
                _isDisposing = true;
                _fileWatcher.FileChanged -= FileWatcher_FileChanged;
+               // If you choose to implement ConfigurationChanged event subscription
+               // _logFactory.ConfigurationChanged -= LogFactory_ConfigurationChanged;
                lock (_lockObject)
                {
                    var reloadTimer = _reloadTimer;
                    _reloadTimer = null;
                    reloadTimer?.Dispose();
                }
                _fileWatcher.Dispose();
+               TryUnwatchConfigFile(); // Ensure file watching is stopped
            }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f5105f3 and 2c9d478.

📒 Files selected for processing (7)
  • src/NLog.AutoReloadConfig/NLog.AutoReloadConfig.csproj (0 hunks)
  • src/NLog.AutoReloadConfig/README.md (0 hunks)
  • src/NLog.AutoReloadConfig/SetupBuilderAutoReloadExtensions.cs (0 hunks)
  • src/NLog.sln (0 hunks)
  • src/NLog/Config/XmlLoggingConfiguration.cs (5 hunks)
  • tests/NLog.AutoReloadConfig.Tests/NLog.AutoReloadConfig.Tests.csproj (0 hunks)
  • tests/NLog.UnitTests/Config/AutoReloadTests.cs (9 hunks)
💤 Files with no reviewable changes (5)
  • src/NLog.sln
  • src/NLog.AutoReloadConfig/README.md
  • tests/NLog.AutoReloadConfig.Tests/NLog.AutoReloadConfig.Tests.csproj
  • src/NLog.AutoReloadConfig/SetupBuilderAutoReloadExtensions.cs
  • src/NLog.AutoReloadConfig/NLog.AutoReloadConfig.csproj
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/NLog.UnitTests/Config/AutoReloadTests.cs

@snakefoot snakefoot changed the title XmlLoggingConfiguration - AutoReload available by default XmlLoggingConfiguration - AutoReload available by default (again) Apr 24, 2025
@snakefoot snakefoot changed the title XmlLoggingConfiguration - AutoReload available by default (again) XmlLoggingConfiguration - AutoReload available by default as before Apr 24, 2025
@snakefoot snakefoot added the breaking change Breaking API change (different to semantic change) label Apr 24, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (3)
src/NLog/Config/XmlLoggingConfiguration.cs (3)

575-575: ⚠️ Potential issue

Thread-safety: make _isDisposing volatile

_isDisposing is read from multiple threads (timer thread, FileSystemWatcher thread) without a lock. Without the volatile modifier there is no guarantee other threads will observe the write performed in Dispose(), leading to possible use-after-dispose race conditions.

-            private bool _isDisposing;
+            private volatile bool _isDisposing;

56-57: ⚠️ Potential issue

Fix potential memory leak in static _watchers dictionary

The _watchers dictionary maintains strong references to LogFactory instances, but entries are never removed when factories are disposed or auto-reload is disabled.

Update the OnConfigurationAssigned method to remove disposed entries:

                    if (fileWatcher != null)
                    {
                        InternalLogger.Info("AutoReload Config File Monitor stopping, since no active configuration");
                        fileWatcher.Dispose();
+                        lock (_watchers)
+                        {
+                            _watchers.Remove(configFactory);
+                        }
                    }

579-583: 🛠️ Refactor suggestion

Missing event subscription for LogFactory_ConfigurationChanged

The class implements a method for handling LogFactory.ConfigurationChanged events, but never subscribes to this event in the constructor or unsubscribes in Dispose().

Either wire up the event handler or remove the unused method to avoid confusion:

            public AutoReloadConfigFileWatcher(LogFactory logFactory)
            {
                _logFactory = logFactory;
                _fileWatcher.FileChanged += FileWatcher_FileChanged;
+                _logFactory.ConfigurationChanged += LogFactory_ConfigurationChanged;
            }

            // And in Dispose():
            public void Dispose()
            {
                _isDisposing = true;
                _fileWatcher.FileChanged -= FileWatcher_FileChanged;
+                _logFactory.ConfigurationChanged -= LogFactory_ConfigurationChanged;
                lock (_lockObject)
                {
                    var reloadTimer = _reloadTimer;
                    _reloadTimer = null;
                    reloadTimer?.Dispose();
                }
                _fileWatcher.Dispose();
            }
🧹 Nitpick comments (1)
tests/NLog.UnitTests/Config/ReloadTests.cs (1)

530-533: Consider migrating remaining uses of obsolete property

While pragma directives correctly suppress the warning, for consistency and future maintenance it would be better to migrate these remaining usages to AutoReloadFileNames as well.

-#pragma warning disable CS0618 // Type or member is obsolete
-                Assert.Single(logFactory.Configuration.FileNamesToWatch);
-                Assert.Equal(mainConfigFilePath, logFactory.Configuration.FileNamesToWatch.FirstOrDefault());
-#pragma warning restore CS0618 // Type or member is obsolete
+                Assert.Single(((XmlLoggingConfiguration)logFactory.Configuration).AutoReloadFileNames);
+                Assert.Equal(mainConfigFilePath, ((XmlLoggingConfiguration)logFactory.Configuration).AutoReloadFileNames.FirstOrDefault());
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c62ea33 and 2904583.

📒 Files selected for processing (12)
  • build.ps1 (0 hunks)
  • run-tests.ps1 (0 hunks)
  • src/NLog.AutoReloadConfig/NLog.AutoReloadConfig.csproj (0 hunks)
  • src/NLog.AutoReloadConfig/README.md (0 hunks)
  • src/NLog.AutoReloadConfig/SetupBuilderAutoReloadExtensions.cs (0 hunks)
  • src/NLog.sln (0 hunks)
  • src/NLog/Config/LoggingConfiguration.cs (2 hunks)
  • src/NLog/Config/XmlLoggingConfiguration.cs (6 hunks)
  • tests/NLog.AutoReloadConfig.Tests/NLog.AutoReloadConfig.Tests.csproj (0 hunks)
  • tests/NLog.UnitTests/Config/AutoReloadTests.cs (9 hunks)
  • tests/NLog.UnitTests/Config/ReloadTests.cs (12 hunks)
  • tests/NLog.UnitTests/ConfigFileLocatorTests.cs (1 hunks)
💤 Files with no reviewable changes (7)
  • build.ps1
  • run-tests.ps1
  • src/NLog.AutoReloadConfig/README.md
  • src/NLog.sln
  • tests/NLog.AutoReloadConfig.Tests/NLog.AutoReloadConfig.Tests.csproj
  • src/NLog.AutoReloadConfig/NLog.AutoReloadConfig.csproj
  • src/NLog.AutoReloadConfig/SetupBuilderAutoReloadExtensions.cs
✅ Files skipped from review due to trivial changes (3)
  • tests/NLog.UnitTests/Config/AutoReloadTests.cs
  • tests/NLog.UnitTests/ConfigFileLocatorTests.cs
  • src/NLog/Config/LoggingConfiguration.cs
🔇 Additional comments (4)
tests/NLog.UnitTests/Config/ReloadTests.cs (1)

98-99: Code successfully updated to use new AutoReloadFileNames property

All test assertions have been correctly updated to reference the new AutoReloadFileNames property instead of the obsolete FileNamesToWatch property. This maintains test coverage while adhering to the new API.

Also applies to: 107-108, 116-117, 161-162, 170-171, 181-182, 299-299, 307-307, 318-318, 365-366, 374-375, 432-434, 442-444, 452-454, 511-513, 521-522

src/NLog/Config/XmlLoggingConfiguration.cs (3)

183-186: Appropriate use of obsolete attribute

Good implementation of backward compatibility by marking the FileNamesToWatch property as obsolete and delegating to the new AutoReloadFileNames property.


206-249: Well-implemented configuration lifecycle management

The OnConfigurationAssigned method correctly handles the lifecycle of file watchers based on configuration changes. The use of locking for thread safety and proper error handling is commendable.


569-712: Well-implemented auto-reload mechanism

The AutoReloadConfigFileWatcher class provides a robust implementation with:

  • Appropriate debouncing through timer usage
  • Thread-safe coordination of file watching and reloading
  • Proper error handling to prevent crashes
  • Clean disposal of resources

The integration of this functionality directly into XmlLoggingConfiguration ensures the feature works out of the box.

@snakefoot snakefoot force-pushed the autoreload branch 2 times, most recently from f04f517 to a9f9507 Compare April 24, 2025 08:54
@snakefoot snakefoot force-pushed the autoreload branch 2 times, most recently from 67efed0 to 425f105 Compare April 24, 2025 08:56
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
79.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@snakefoot snakefoot merged commit a125116 into NLog:dev Apr 24, 2025
5 of 6 checks passed
@snakefoot snakefoot added platform support and removed breaking change Breaking API change (different to semantic change) labels Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant