Plinth.Logging.NLog
1.8.0
Prefix Reserved
dotnet add package Plinth.Logging.NLog --version 1.8.0
NuGet\Install-Package Plinth.Logging.NLog -Version 1.8.0
<PackageReference Include="Plinth.Logging.NLog" Version="1.8.0" />
<PackageVersion Include="Plinth.Logging.NLog" Version="1.8.0" />
<PackageReference Include="Plinth.Logging.NLog" />
paket add Plinth.Logging.NLog --version 1.8.0
#r "nuget: Plinth.Logging.NLog, 1.8.0"
#:package Plinth.Logging.NLog@1.8.0
#addin nuget:?package=Plinth.Logging.NLog&version=1.8.0
#tool nuget:?package=Plinth.Logging.NLog&version=1.8.0
README
Plinth.Logging.NLog
NLog logging via Plinth
1. Create a new file called NLog.config in your project root.
- Place the XML below inside this file.
- Right Click - Properties - Copy to Output Directory - Set to "Copy If Newer"
- {Project}.csproj
<ItemGroup>
<None Update="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
- NLog.config
<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="true" throwExceptions="false" internalLogLevel="Off"
internalLogFile="Logs/nlog-internal.log">
<variable name="product" value="PRODUCT" />
<variable name="component" value="COMPONENT" />
-->
<variable name="exceptionRootDirPrefixes" value="Plinth,YourNamespace" />
<include file="${basedir}/NLog.Plinth.config" ignoreErrors="true" />
<rules>
</rules>
</nlog>
2. NLog.config configurations
- Uncomment one of the logger lines unside the rules section
- set environment to something like
local,dev,prod, etc - set product to your product name
- set component to the component name (like core, web, reports, etc)
- set exceptionRootDirPrefixes to the beginning of the root path of your component (for filtering filenames in stack traces)
3a. Use this code in Program.cs
public static class Program
{
public static void Main(string[] args)
{
var log = StaticLogManagerSetup.BasicNLogSetup();
log.Debug("startup!");
3b. Add this to your host setup
webBuilder.ConfigureLogging(builder => builder.AddNLog());
OR
webBuilder.ConfigureServices(services => services.AddNLog());
3c. Add this code to your classes
using Microsoft.Extensions.Logging;
class MyClass
{
private static readonly ILogger log = StaticLogManager.GetLogger();
OR inject via DI
public MyClass(ILogger<MyClass> logger)
4. Configuration
By default, Microsoft.* and System.* will be set to Warn and above only.
To turn those on, add rules in NLog.config like this, which will enable Info and above
<logger name="Microsoft.*" maxLevel="Debug" final="true" />
👉 NOTE: When using NLog, appsettings.json / "Logging" has no effect, it is all configured through NLog.config
5. Overrides
Use this to override file archiving parameters in
NLog.Plinth.config- Create a new file called
NLog.Plinth.Overrides.configin your root. - Place the XML below inside this file.
- Right Click - Properties - Copy to Output Directory - Set to
Copy If Newer
- Create a new file called
{Project}.csproj
<ItemGroup>
<None Update="NLog.Plinth.Overrides.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
- NLog.Plinth.Overrides.config
<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="true" throwExceptions="false" internalLogLevel="Off"
internalLogFile="Logs\nlog-internal.log">
<variable name="file.archiveAboveSize" value="10485760"/>
<variable name="file.maxArchiveFiles" value="10"/>
<variable name="file.enableCompression" value="true"/>
</nlog>
- To override the file name for this config (for different environments, etc, add this above the include for NLog.Plinth.config)
<variable name="plinthOverrideConfig" value="NLog.Plinth.Overrides.PROD.config"/>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Logging (>= 10.0.0)
- NLog (>= 5.5.1 && < 6.0.0)
- NLog.Extensions.Logging (>= 5.5.0 && < 6.0.0)
- NLog.Schema (>= 5.5.1 && < 6.0.0)
- Plinth.Common (>= 1.8.0)
- Plinth.Serialization (>= 1.8.0)
-
net8.0
- Microsoft.Extensions.Logging (>= 10.0.0)
- NLog (>= 5.5.1 && < 6.0.0)
- NLog.Extensions.Logging (>= 5.5.0 && < 6.0.0)
- NLog.Schema (>= 5.5.1 && < 6.0.0)
- Plinth.Common (>= 1.8.0)
- Plinth.Serialization (>= 1.8.0)
- System.Text.Json (>= 10.0.0)
-
net9.0
- Microsoft.Extensions.Logging (>= 10.0.0)
- NLog (>= 5.5.1 && < 6.0.0)
- NLog.Extensions.Logging (>= 5.5.0 && < 6.0.0)
- NLog.Schema (>= 5.5.1 && < 6.0.0)
- Plinth.Common (>= 1.8.0)
- Plinth.Serialization (>= 1.8.0)
- System.Text.Json (>= 10.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Plinth.Logging.NLog:
| Package | Downloads |
|---|---|
|
Plinth.Logging.NLog.AppInsights
Plinth NLog Target for Application Insights |
|
|
Plinth.WindowsService
Plinth Windows Service Utilities |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.8.0 | 286 | 11/13/2025 |
| 1.8.0-b211.72089fd9 | 229 | 11/12/2025 |
| 1.7.4 | 1,422 | 8/6/2025 |
| 1.7.3 | 94 | 8/2/2025 |
| 1.7.2 | 504 | 3/16/2025 |
| 1.7.1 | 746 | 12/12/2024 |
| 1.7.0 | 2,215 | 11/12/2024 |
| 1.6.6 | 216 | 11/8/2024 |
| 1.6.5 | 2,951 | 8/31/2024 |
| 1.6.4 | 190 | 8/2/2024 |
| 1.6.3 | 449 | 5/15/2024 |
| 1.6.2 | 358 | 2/16/2024 |
| 1.6.1 | 4,379 | 1/5/2024 |
| 1.6.0 | 442 | 11/30/2023 |
| 1.5.10-b186.aca976b4 | 135 | 11/30/2023 |
| 1.5.9 | 231 | 11/29/2023 |
| 1.5.9-b174.64153841 | 115 | 11/23/2023 |
| 1.5.9-b172.dfc6e7bd | 126 | 11/17/2023 |
| 1.5.9-b171.4e2b92e2 | 133 | 11/4/2023 |
| 1.5.8 | 253 | 10/23/2023 |
| 1.5.7 | 6,953 | 7/31/2023 |
| 1.5.6 | 5,426 | 7/13/2023 |
| 1.5.5 | 359 | 6/29/2023 |
| 1.5.4 | 857 | 3/7/2023 |
| 1.5.3 | 461 | 3/3/2023 |
| 1.5.2 | 747 | 1/11/2023 |
| 1.5.2-b92.7c961f5f | 225 | 1/11/2023 |
| 1.5.0 | 758 | 11/9/2022 |
| 1.5.0-b88.7a7c20cd | 204 | 11/9/2022 |
| 1.4.7 | 3,762 | 10/20/2022 |
| 1.4.6 | 1,198 | 10/17/2022 |
| 1.4.5 | 1,352 | 10/1/2022 |
| 1.4.4 | 1,127 | 8/16/2022 |
| 1.4.3 | 1,522 | 8/2/2022 |
| 1.4.2 | 1,275 | 7/19/2022 |
| 1.4.2-b80.7fdbfd04 | 251 | 7/19/2022 |
| 1.4.2-b74.acaf86f5 | 230 | 6/15/2022 |
| 1.4.1 | 1,292 | 6/13/2022 |
| 1.4.0 | 1,132 | 6/6/2022 |
| 1.3.8 | 2,429 | 4/12/2022 |
| 1.3.7 | 1,166 | 3/21/2022 |
| 1.3.6 | 1,166 | 3/17/2022 |
| 1.3.6-b67.ca5053f3 | 255 | 3/16/2022 |
| 1.3.6-b66.4a9683e6 | 239 | 3/16/2022 |
| 1.3.5 | 1,248 | 2/23/2022 |
| 1.3.4 | 1,689 | 1/20/2022 |
| 1.3.3 | 1,012 | 12/29/2021 |
| 1.3.2 | 892 | 12/11/2021 |
| 1.3.1 | 764 | 11/12/2021 |
| 1.3.0 | 786 | 11/8/2021 |
| 1.2.3 | 2,037 | 9/22/2021 |
| 1.2.2 | 1,036 | 8/20/2021 |
| 1.2.1 | 1,519 | 8/5/2021 |
| 1.2.0 | 911 | 8/1/2021 |
| 1.2.0-b37.a54030b9 | 300 | 6/24/2021 |
| 1.1.6 | 3,766 | 3/22/2021 |
| 1.1.5 | 1,050 | 3/9/2021 |
| 1.1.4 | 1,910 | 2/27/2021 |
| 1.1.3 | 980 | 2/17/2021 |
| 1.1.2 | 1,062 | 2/12/2021 |
| 1.1.1 | 1,339 | 2/1/2021 |
| 1.1.0 | 1,013 | 12/16/2020 |
| 1.1.0-b27.b66c309b | 439 | 11/15/2020 |
| 1.0.12 | 2,997 | 10/18/2020 |
| 1.0.11 | 1,051 | 10/6/2020 |
| 1.0.10 | 1,016 | 9/30/2020 |
| 1.0.9 | 873 | 9/29/2020 |
| 1.0.8 | 969 | 9/26/2020 |
| 1.0.7 | 903 | 9/19/2020 |
| 1.0.6 | 836 | 9/3/2020 |
| 1.0.5 | 813 | 9/2/2020 |
| 1.0.4 | 1,204 | 9/1/2020 |
| 1.0.3 | 875 | 9/1/2020 |
| 1.0.2 | 827 | 8/29/2020 |
| 1.0.1 | 837 | 8/29/2020 |
| 1.0.0 | 879 | 8/29/2020 |
| 1.0.0-b1.c22f563d | 392 | 8/28/2020 |
net10.0 support