Symbol.Logger.NLog 1.0.1.1

dotnet add package Symbol.Logger.NLog --version 1.0.1.1                
NuGet\Install-Package Symbol.Logger.NLog -Version 1.0.1.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="Symbol.Logger.NLog" Version="1.0.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Symbol.Logger.NLog --version 1.0.1.1                
#r "nuget: Symbol.Logger.NLog, 1.0.1.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 Symbol.Logger.NLog as a Cake Addin
#addin nuget:?package=Symbol.Logger.NLog&version=1.0.1.1

// Install Symbol.Logger.NLog as a Cake Tool
#tool nuget:?package=Symbol.Logger.NLog&version=1.0.1.1                

Infrastructure Symbol.Logger.NLog

基于 NLog。

支持运行时:

  • .NET Framework 3.5
  • .NET Framework 4.0
  • .NET Framework 4.5
  • .NET Framework 4.6.2
  • .NET Framework 4.8
  • .NET Standard 2.0
  • .NET 6.0
  • .NET 7.0
  • .NET 8.0

调用代码

using Symbol.Logger;

class Program {
    static void Main(){
        //设置全局日志提供者。
        LoggerProvider.SetProvider(ConfigurationManager.AppSettings["LoggerProvider"]);
	}
}

App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
    </sectionGroup>
  </configSections>
  <appSettings>
    <add key="LoggerProvider" value="NLog" />
  </appSettings>
</configuration>

NLog.config

最终级项目中,包含一个名为“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="${specialfolder:folder=MyDocuments:cached=true}/${companyName}/${appName}/${dirName}/nlog-internal.log">
	<variable name="companyName" value="YourCompanyName"/>
	<variable name="appName" value="YourAppName"/>
	<variable name="dirName" value="Logs"/>
	<targets>
		<target name="logfileObservableObject"
				xsi:type="File"
				fileName="${specialfolder:folder=MyDocuments:cached=true}/${companyName}/${appName}/${dirName}/observableObject-info-${shortdate}-current.log"
				layout="${longdate} [${uppercase:${level}}] ${message} ${exception:format=ToString}"
				maxArchiveFiles="30"
				archiveFileName="${specialfolder:folder=MyDocuments:cached=true}/${companyName}/${appName}/${dirName}/observableObject-info-${shortdate}-archive${###}.log"
				createDirs="true"
				archiveAboveSize="102400"
				archiveEvery="Day"
				encoding="UTF-8"
		/>
		<target name="logfileObservableObjectDebug"
				xsi:type="File"
				fileName="${specialfolder:folder=MyDocuments:cached=true}/${companyName}/${appName}/${dirName}/observableObject-debug-${shortdate}-current.log"
				layout="${longdate} [${uppercase:${level}}] ${message} ${exception:format=ToString}"
				maxArchiveFiles="30"
				archiveFileName="${specialfolder:folder=MyDocuments:cached=true}/${companyName}/${appName}/${dirName}/observableObject-debug-${shortdate}-archive${###}.log"
				createDirs="true"
				archiveAboveSize="204800"
				archiveEvery="Day"
				encoding="UTF-8"
		/>
		<target name="logfileOther"
				xsi:type="File"
				fileName="${specialfolder:folder=MyDocuments:cached=true}/${companyName}/${appName}/${dirName}/other-${shortdate}-current.log"
				layout="${longdate} [${uppercase:${level}}] ${logger} ${message} ${exception:format=ToString}"
				maxArchiveFiles="30"
				archiveFileName="${specialfolder:folder=MyDocuments:cached=true}/${companyName}/${appName}/${dirName}/other-${shortdate}-archive${###}.log"
				createDirs="true"
				archiveAboveSize="102400"
				archiveEvery="Day"
				encoding="UTF-8"
		/>
		<target name="logconsole" xsi:type="Console"
				layout="${longdate} [${uppercase:${level}}] ${callsite}(${callsite-filename:includeSourcePath=False}:${callsite-linenumber}) - ${message} ${exception:format=ToString}"
		/>
	</targets>
	<rules>
		
		<logger name="Symbol.Logger.DebugTime"  writeTo="logfileObservableObjectDebug" />
		<logger name="LoggerObservableObject.*" levels="Trace,Debug" writeTo="logfileObservableObjectDebug" />
		<logger name="LoggerObservableObject.*" levels="Info,Error,Warn,Fatal" writeTo="logfileObservableObject"/>
		
	</rules>
</nlog>

模板说明:

  • YourCompanyName:公司名称。 <variable name="companyName" value="YourCompanyName"/>
  • YourAppName:产品名称。 <variable name="appName" value="YourAppName"/>
  • 保存位置:保存到“我的文档”目录。 ${specialfolder:folder=MyDocuments:cached=true}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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 is compatible.  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. 
.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 net35 is compatible.  net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  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.
  • .NETFramework 3.5

  • .NETFramework 4.0

  • .NETFramework 4.5

  • .NETFramework 4.6.2

  • .NETFramework 4.8

  • .NETStandard 2.0

  • net6.0

  • net7.0

  • net8.0

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
1.0.1.1 145 2/23/2024

Infrastructure: Symbol.Logger.NLog