CSoft.LogInterface
6.0.1
.NET 5.0
This package targets .NET 5.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.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package CSoft.LogInterface --version 6.0.1
NuGet\Install-Package CSoft.LogInterface -Version 6.0.1
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.LogInterface" Version="6.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CSoft.LogInterface --version 6.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CSoft.LogInterface, 6.0.1"
#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.LogInterface as a Cake Addin #addin nuget:?package=CSoft.LogInterface&version=6.0.1 // Install CSoft.LogInterface as a Cake Tool #tool nuget:?package=CSoft.LogInterface&version=6.0.1
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 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 was computed. 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. |
.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
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on CSoft.LogInterface:
Package | Downloads |
---|---|
CSoft.Communication
通讯物理口封装 |
|
CSoft.Parser
数据分帧解析器 |
|
CSoft.LoggerNLog
使用NLog输出日志 |
|
CSoft.Process
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
日志接口