Cola.Log 3.0.0

dotnet add package Cola.Log --version 3.0.0
                    
NuGet\Install-Package Cola.Log -Version 3.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="Cola.Log" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cola.Log" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Cola.Log" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cola.Log --version 3.0.0
                    
#r "nuget: Cola.Log, 3.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.
#:package Cola.Log@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cola.Log&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Cola.Log&version=3.0.0
                    
Install as a Cake Tool
ColaLog 日志组件
简介

ColaLog日志组件,可以生成日志并保存。保存可以保存为文件、或保存到数据库或全部。日志文件保存路径为 bin/logs/ 其中logs目录如果不存在会自动生成。

控制台 Info信息输出绿色文字、waring信息输出蓝色文字、Error信息输出红色文字

配置文件配置
{
  "ColaLogs":{
    "LogSeparator":"*",
    "LogTimeFormat":"yyyy-MM-dd HH:mm:ss",
    /*
    保存形式为 File、SqlServer、MySql、All、不配置, 效果分别为
    保存到 文件、sqlserver数据库、mysql数据库、所有(即保存文件又保存数据库)、仅打印
    配置方式如下
    "SaveType":"File,MySql" 或者 "SaveType":"All"  或者 "SaveType":""
    */
    "SaveType":"File",
    // 保存log的数据库链接字符串
    "DbConnectionString": "",
    // 日志文件夹名称
    "DirectoryName": "ColaLogs",
    // 日志保留时间 单位 天
    "KeepTime":10
  }
}
注入方式
//通过配置文件注入 AddScopedColaLogs  AddTransientColaLogs
builder.Services.AddSingletonColaLogs(config);

// 直接注入  AddScopedColaLogs  AddTransientColaLogs
builder.Services.AddSingletonColaLogs(option =>
{
    option.Config = new LogConfig()
    {
        LogTimeFormat = "yyyy-MM-dd HH:mm:ss",
        LogSeparator = "=",
        SaveType = "",
        DbConnectionString = ""
    };
});
使用方式
// Info 输出   控制台绿色文字
 Log.Info(exception.Message);
// Waring 输出   控制台蓝色文字
 Log.Waring(exception.StackTrace);
// Error 输出   控制台红色文字
 Log.Error(exception);
Product 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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Cola.Log:

Package Downloads
Cola.Core

Cola.Core.

Cola.Exception

Cola.Exception.

Cola.FilterExtensions

Cola.FilterExtensions.

Cola.Middlewares

Cola.Middlewares.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 317 3/8/2025
2.0.0 276 3/7/2025
1.1.0 267 3/7/2025