CSoft.LoggerNLog
9.0.0
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package CSoft.LoggerNLog --version 9.0.0
NuGet\Install-Package CSoft.LoggerNLog -Version 9.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSoft.LoggerNLog" Version="9.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CSoft.LoggerNLog --version 9.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CSoft.LoggerNLog, 9.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CSoft.LoggerNLog as a Cake Addin #addin nuget:?package=CSoft.LoggerNLog&version=9.0.0 // Install CSoft.LoggerNLog as a Cake Tool #tool nuget:?package=CSoft.LoggerNLog&version=9.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Log
日志存储
第一步
一般情况,可加参数表示指定文件名
Logs.LogFactory = new NLogFactory();
Android下自动读取Assets下的配置
Logs.LogFactory = new NLogFactory("assets/NLog.config");
第二步
Android下的配置文件,其他的无非给下路径,Android下路径不熟,给个例子,详见文章尾部摘抄
<?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="c:\temp\nlog-internal.log">
<variable name="myvar" value="myvalue"/>
<variable name="logDir" value="${specialfolder:folder=MyDocuments}/Logs/"/>
<targets async="true">
<target xsi:type="File" name="error" fileName="${logDir}/Error/${shortdate}.log" layout="${level:upperCase=true} ${longdate} ${logger} ${callsite:skipFrames=2} ${message} ${onexception:${newline} ${exception:format=toString,Data} ${newline} ${stacktrace} ${newline}"/>
<target xsi:type="File" name="info" fileName="${logDir}/Info/${shortdate}.log" layout="${level:upperCase=true} ${longdate} ${logger} ${callsite:skipFrames=2} ${message}"/>
<target xsi:type="File" name="warn" fileName="${logDir}/Warn/${shortdate}.log" layout=" ${level:upperCase=true} ${longdate} ${logger} ${callsite:skipFrames=2} ${message} ${onexception:${newline} ${exception:format=toString,Data} ${newline} ${stacktrace} ${newline}"/>
<target xsi:type="File" name="trace" fileName="${logDir}/Trace/${shortdate}.log" layout=" ${longdate} ${message}"/>
<target xsi:type="File" name="debug" fileName="${logDir}/Debug/${shortdate}.log" layout=" ${longdate} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Error" maxlevel="Error" writeTo="error"/>
<logger name="*" minlevel="Info" maxlevel="Info" writeTo="info"/>
<logger name="*" minlevel="Warn" maxlevel="Warn" writeTo="warn"/>
<logger name="*" minlevel="Trace" maxlevel="Trace" writeTo="trace"/>
<logger name="*" minlevel="Debug" maxlevel="Debug" writeTo="debug"/>
</rules>
</nlog>
第三步
在使用到的类中加入
//Main是你需要调用的类
private static readonly ILogger _logger = Logs.LogFactory.GetLogger<Main>();
第四步
可在需要位置输出日志,比如:
_logger.Info("hello");
_logger.Error(e.Exception);
*附NLog文件路径规则
System special folder path (includes My Documents, My Music, Program Files, Desktop, and more).
Platforms Supported: Limited (Not supported on NetStandard1.3+1.5)
See also ${processdir} , ${basedir} , ${currentdir} , ${tempdir}
Configuration Syntax
${specialfolder:dir=String:file=String:folder=Enum}
Parameters
Advanced Options
- dir - Name of the directory to be Path.Combine()'d with the directory name.
- file - Name of the file to be Path.Combine()'d with the directory name.
Rendering Options
folder - System special folder to use. Full list of options is available at MSDN. The most common ones are:
- ApplicationData - Roaming application data for current user
- Windows Path =
C:\Users\%USERNAME%\AppData\Roaming
- Xamarin Mono =
$HOME/.config
(or $XDG_CONFIG_HOME if set) - Xamarin iOS =
/data/Containers/Data/Application/@GENERATED_NAME@/Documents/.config
- Xamarin Android =
/data/data/@PACKAGE_NAME@/files/.config
- Windows Path =
- LocalApplicationData - Non roaming application data for current user
- Windows Path =
C:\Users\%USERNAME%\AppData\Local
- Xamarin Mono =
$HOME/.local/share
(or $XDG_DATA_HOME if set) - Xamarin iOS =
/data/Containers/Data/Application/@GENERATED_NAME@/Documents
- Xamarin Android =
/data/data/@PACKAGE_NAME@/files/.local/share
- Windows Path =
- CommonApplicationData - Application data for all users (Good when running as Windows Service)
- Windows Path =
C:\ProgramData
- Xamarin Mono =
/usr/share
- Xamarin iOS =
/usr/share
- Xamarin Android =
/usr/share
- Windows Path =
- MyDocuments - My Documents
- Windows Path =
C:\Users\%USERNAME%\Documents
- Xamarin Mono =
$HOME
- Xamarin iOS =
/data/Containers/Data/Application/@GENERATED_NAME@/Documents
- Xamarin Android =
/data/data/@PACKAGE_NAME@/files
- Windows Path =
- Desktop - My Desktop
- Windows Path =
C:\Users\%USERNAME%\Desktop
- Xamarin Mono =
$HOME/Desktop
(or $XDG_DESKTOP_DIR if set) - Xamarin iOS =
/data/Containers/Data/Application/@GENERATED_NAME@/Documents/Desktop
- Xamarin Android =
/data/data/@PACKAGE_NAME@/files/Desktop
- Windows Path =
- UserProfile
- Windows Path =
C:\Users\%USERNAME%
- Xamarin Mono =
$HOME
- Xamarin iOS =
/data/Containers/Data/Application/@GENERATED_NAME@
- Xamarin Android =
/data/data/@PACKAGE_NAME@/files
- Windows Path =
- Templates
- Windows Path =
C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Templates
- Xamarin Mono =
$HOME/Templates
(or $XDG_TEMPLATES_DIR if set) - Xamarin iOS =
/data/Containers/Data/Application/@GENERATED_NAME@/Documents/Templates
- Xamarin Android =
/data/data/@PACKAGE_NAME@/files/Templates
- Windows Path =
- CommonTemplates
- Windows Path =
C:\ProgramData\Microsoft\Windows\Templates
- Xamarin Mono =
/usr/share/templates
- Xamarin iOS =
/usr/share/templates
- Xamarin Android =
/usr/share/templates
- Windows Path =
- Resources
- Windows Path =
C:\WINDOWS\resources
- Xamarin iOS =
/Library
- Windows Path =
- AdminTools
- CommonAdminTools
- CommonDesktopDirectory
- CommonDocuments
- CommonMusic
- CommonPictures
- CommonProgramFiles
- CommonProgramFilesX86
- CommonPrograms
- CommonStartMenu
- CommonStartup
- CommonVideos
- Cookies
- DesktopDirectory (Same as Desktop)
- Favorites
- Fonts
- History
- LocalizedResources
- MyComputer
- MyMusic
- MyPictures
- MyVideos
- NetworkShortcuts
- Personal (Same as MyDocuments)
- PrinterShortcuts
- ProgramFiles
- ProgramFilesX86
- Programs
- Recent
- SendTo
- StartMenu
- Startup
- System
- SystemX86
- Windows
- ApplicationData - Roaming application data for current user
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- CSoft.LogInterface (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- NLog (>= 5.3.4)
- System.Text.Json (>= 9.0.0)
-
net8.0
- CSoft.LogInterface (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- NLog (>= 5.3.4)
-
net9.0
- CSoft.LogInterface (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- NLog (>= 5.3.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
9.0.0 | 78 | 11/22/2024 | |
8.0.2 | 125 | 7/10/2024 | |
8.0.1 | 239 | 12/29/2023 | |
8.0.0 | 201 | 11/15/2023 | |
7.0.4 | 180 | 8/22/2023 | |
7.0.3 | 203 | 6/13/2023 | |
7.0.2 | 223 | 4/21/2023 | |
7.0.1 | 341 | 2/2/2023 | |
7.0.0 | 441 | 11/9/2022 | |
6.0.5 | 501 | 9/23/2022 | |
6.0.4 | 524 | 8/11/2022 | |
6.0.3 | 504 | 6/1/2022 | |
6.0.2 | 498 | 5/12/2022 | |
6.0.1 | 525 | 3/15/2022 | |
5.0.5 | 641 | 8/18/2021 | |
5.0.4 | 471 | 4/29/2021 | |
5.0.3 | 500 | 3/11/2021 | |
5.0.2 | 535 | 1/22/2021 | |
5.0.1 | 515 | 1/21/2021 | |
5.0.0 | 510 | 1/20/2021 |
更新依赖