CodeWF.Toolkit.Logging 1.1.10

dotnet add package CodeWF.Toolkit.Logging --version 1.1.10
                    
NuGet\Install-Package CodeWF.Toolkit.Logging -Version 1.1.10
                    
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="CodeWF.Toolkit.Logging" Version="1.1.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodeWF.Toolkit.Logging" Version="1.1.10" />
                    
Directory.Packages.props
<PackageReference Include="CodeWF.Toolkit.Logging" />
                    
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 CodeWF.Toolkit.Logging --version 1.1.10
                    
#r "nuget: CodeWF.Toolkit.Logging, 1.1.10"
                    
#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 CodeWF.Toolkit.Logging@1.1.10
                    
#: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=CodeWF.Toolkit.Logging&version=1.1.10
                    
Install as a Cake Addin
#tool nuget:?package=CodeWF.Toolkit.Logging&version=1.1.10
                    
Install as a Cake Tool

CodeWF.Toolkit.Logging

轻量级日志核心库:控制台输出、文件轮转日志与 UI 日志事件,适合控制台、桌面等 .NET 应用统一接入日志能力。Lightweight logging core with console output, rotating file logs and UI log events.

NuGet License

安装

dotnet add package CodeWF.Toolkit.Logging

仅依赖 Microsoft.Extensions.Logging.Abstractions 与本仓 CodeWF.Toolkit.Lang(随包自动安装);目标框架 net10.0。需要把 Microsoft.Extensions.Logging 生态日志接入本核心时,再叠加 CodeWF.Toolkit.Logging.Microsoft。

快速使用

using CodeWF.Toolkit.Logging;

Logger.TryInitialize(new LoggerOptions
{
    MinimumLevel = LogLevel.Information,
    EnableConsole = true,
    File = new FileLogOptions
    {
        DirectoryPath = Path.Combine(AppContext.BaseDirectory, "logs"),
        MaxFileSizeBytes = 32 * 1024 * 1024,
        RetentionDays = 30,
    },
    // LineTemplate 可自定义输出模板(LineTemplateController.DefaultTemplate)
});

Logger.Info("服务已启动");
Logger.Warn("磁盘空间不足");
Logger.Error("处理失败", ex);

await Logger.ShutdownAsync();   // 退出前刷盘

要点:

  • LoggerOptions 为 record:MinimumLevel、EnableConsole、File(轮转/保留策略/批量写入)、LineTemplate、LocalizedLevelFormatter。
  • LogEventFeed 暴露 UI 日志事件快照,供日志查看控件订阅(配合 CodeWF.Avalonia.Log)。
  • LoggerSelfDiagnostics 输出日志系统自身的诊断信息。
  • 运行时文案使用嵌入的中英文资源,应用可用同名键覆盖。

注意事项

  • UI 事件流回调在后台线程触发,界面订阅方需自行调度到 UI 线程。
  • 文件写入为批量异步,崩溃前请调用 ShutdownAsync()。

文档

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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 CodeWF.Toolkit.Logging:

Package Downloads
CodeWF.Avalonia.Markdown

Markdown 完整包:在 Lite 渲染引擎之上提供图片(GIF/SVG/预览)、数学公式、Mermaid 图表、TextMate 代码高亮、行内样式(span style 字号/前景色/背景色,含选区浮动条与可读性回退)、PNG/PDF/Word/公众号 HTML 导出,以及源码编辑器与单栏实时编辑(所见即所得)控件,并内置能力控件主题。Full Markdown package: images, math, mermaid, highlighting, inline span styles (font size / foreground / background with selection bar and readability fallback), export and editors on top of the Lite engine.

CodeWF.Avalonia.Log

面向 Avalonia 的日志查看控件与桌面通知:基于轻量日志核心展示实时日志、级别过滤与界面友好内容,适合桌面应用内嵌日志观察台。Avalonia log viewer control with desktop notifications on top of the lightweight logging core.

CodeWF.Toolkit.NetWrapper

TCP/UDP 通信封装与命令分发:客户端/服务端、心跳、断线重连,内置远程文件系统与断点续传能力。TCP/UDP helpers and command dispatching with built-in remote file system and resumable file transfer.

CodeWF.Toolkit.Logging.Microsoft

Microsoft.Extensions.Logging 提供程序,将应用日志统一接入轻量日志核心。Microsoft.Extensions.Logging provider bridging to the lightweight logging core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.10 89 11/20/2026
1.1.9 123 11/16/2026
1.1.8 126 11/16/2026
1.1.7 152 11/16/2026
1.1.6 515 11/8/2026
1.1.5 78 11/8/2026
1.1.4 121 11/8/2026
1.1.3 79 11/8/2026
1.1.2 187 11/1/2026
1.1.1 129 10/26/2026
1.1.0 127 10/22/2026
1.1.0-alpha.1 83 10/21/2026
1.0.0.27 128 10/19/2026
1.0.0.26 193 10/16/2026
1.0.0.25 121 10/16/2026
1.0.0.24 139 10/15/2026
1.0.0.23 131 10/15/2026
1.0.0.22 129 10/15/2026
1.0.0.20 121 10/15/2026
1.0.0.19 1,773 10/15/2026
Loading failed