QinSoft.Log 2.2.0

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

// Install QinSoft.Log as a Cake Tool
#tool nuget:?package=QinSoft.Log&version=2.2.0

QinSoft.Log

QinSoft框架下的Log组件,实现了控制台日志、文件日志和Api日志等。

使用方法

推荐使用配置文件方式使用该组件,减少代码耦合并提高可维护性。

配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="log" type="QinSoft.Log.Config.LogSection, QinSoft.Log"/>
  </configSections>

  <log appId="0d8348ec-1204-4c13-a354-70529674e157" appSecret="QinSoft">
    
    <targets>
      <target key="ConsoleLog" type="QinSoft.Log.Core.ConsoleLogImp, QinSoft.Log"></target>
      <target key="FileLog" type="QinSoft.Log.Core.FileLogImp, QinSoft.Log" filePathFormat="'Log\\${Type}\\${Level}\\'yyyyMMdd.'log'" threadCount="3" maxQueueCount="20000"></target>
      <target key="ApiLog" type="QinSoft.Log.Core.ApiLogImp, QinSoft.Log" logApiUrl="http://localhost/QinSoft.Log.Web/Api/LogApi">
        <fieldMappers>
          <fieldMapper fieldName="AppID" fieldFormat="${AppID}"></fieldMapper>
          <fieldMapper fieldName="Sign" fieldFormat="${Sign}"></fieldMapper>
          <fieldMapper fieldName="TimeStamp" fieldFormat="${TimeStamp}" fieldType="System.Int64"></fieldMapper>
          <fieldMapper fieldName="LogType" fieldFormat="${Type}" fieldType="QinSoft.Log.Core.LogType, QinSoft.Log"></fieldMapper>
          <fieldMapper fieldName="LogLevel" fieldFormat="${Level}" fieldType="QinSoft.Log.Core.LogLevel, QinSoft.Log"></fieldMapper>
          <fieldMapper fieldName="LogAction" fieldFormat="${Action}"></fieldMapper>
          <fieldMapper fieldName="LogMessage" fieldFormat="${Message}"></fieldMapper>
          <fieldMapper fieldName="LogException" fieldFormat="${Exception}"></fieldMapper>
        </fieldMappers>
      </target>
    </targets>

    <rules>
      <rule minLogLevel="Success" targetKey="FileLog"></rule>
      <rule minLogLevel="Debug" maxLogLevel="Debug" targetKey="ConsoleLog"></rule>
    </rules>
  </log>
</configuration>

调用方法

1. LogManager.GetLogger("log").Info(LogType.Default, "Message");
2. "Message".Info(LogType.Default);
Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.2.0 538 12/20/2019
2.1.2 478 9/3/2019
2.1.1 463 9/3/2019
2.1.0 459 9/3/2019
2.0.0 485 8/4/2019
1.0.0 489 6/21/2019

对配置文件格式和逻辑进行修改,完善Api日志接口安全认证逻辑。