You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2025-04-01-nlog-6-0-major-changes.md
+44-31Lines changed: 44 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -3,54 +3,38 @@ layout: post
3
3
title: NLog 6.0 - List of major changes
4
4
---
5
5
6
-
NLog 6.0 is a major version release that introduces breaking changes, including the splitting into multiple NuGet packages, and other improvements to support AOT builds.
6
+
NLog 6.0 is a major version release, and introduces breaking changes to support AOT-builds by splitting into multiple nuget packages.
7
7
8
8
## Major changes
9
9
10
10
### NLog supports AOT
11
11
12
12
NLog has traditionally relied on reflection to dynamically discover requirements for target output.
13
-
But reflection does not always work well with build trimming, and before NLog marked itself to have trimming disabled.
13
+
But reflection does not always work well with build trimming, and before NLog marked itself to be excluded from trimming.
14
14
15
-
NLog includes many features, each of these feature often introduce additional dependencies on the .NET library.
15
+
NLog includes many features, and each feature often introduces additional dependencies on the .NET library.
16
16
This can lead to overhead for AOT builds, as it must include and compile all the relevant source code.
17
17
18
18
NLog v6 attempts to reduce its footprint by extracting several features into separate nuget-packages:
19
19
20
20
- NLog.RegEx - Depends on System.Text.RegularExpressions which is a huge dependency for a logging library.
21
21
- NLog.Targets.ConcurrentFile - ConcurrentWrites using global mutex from operating system API.
22
22
- NLog.Targets.AtomicFile - ConcurrentWrites using atomic file-append from operating system API.
23
+
- NLog.Targets.GZipFile - EnableArchiveFileCompression using GZipStream for writing GZip compressed log-files.
23
24
- NLog.Targets.Mail - Depends on System.Net.Mail.SmtpClient.
24
-
- NLog.Targets.Network - Depends on TCP and UDP Network Socket.
25
+
- NLog.Targets.Network - Depends on TCP and UDP Network Socket, and adds support for Syslog and Graylog.
25
26
- NLog.Targets.Trace - Depends on System.Diagnostics.TraceListener.
26
27
- NLog.Targets.WebService - Depends on System.Net.Http.HttpClient.
27
28
28
-
NLog v6 also no longer supports automatic loading of `NLog.config`-file. This is because dynamic configuration
29
-
loading, prevents build trimming of any NLog types, as the AOT-build cannot determine upfront what types
30
-
will be used by the `NLog.config`-file.
29
+
NLog v6 also no longer depends on `System.Xml.XmlReader`, but now includes its own basic XmlParser for loading `NLog.config` files.
31
30
32
-
### NLog without automatic loading of NLog.config
31
+
NLog v6 still introduces an overhead when compared with just using `Console.WriteLine`,
32
+
but now reduced to 5 MByte in comparison to 14 MBytes with NLog v5.
33
33
34
-
NLog will no longer automatically load the NLog LoggingConfiguration, when creating the first NLog Logger by calling `LogManger.GetCurrentClassLogger()` or `LogManger.GetLogger()`.
35
-
36
-
Instead one must explicit load the `NLog.config` file at application-startup:
When using Microsoft HostBuilder with `UseNLog()`, then it will continue to automatically load the NLog LoggingConfiguration without having to make any changes.
43
-
44
-
.NET Framework will continue to probe NLog LoggingConfiguration from the `app.config` / `web.config`, so one can consider doing this:
0 commit comments