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
<PackageReference Include="CodeWF.Toolkit.Logging" Version="1.1.10" />
<PackageVersion Include="CodeWF.Toolkit.Logging" Version="1.1.10" />
<PackageReference Include="CodeWF.Toolkit.Logging" />
paket add CodeWF.Toolkit.Logging --version 1.1.10
#r "nuget: CodeWF.Toolkit.Logging, 1.1.10"
#:package CodeWF.Toolkit.Logging@1.1.10
#addin nuget:?package=CodeWF.Toolkit.Logging&version=1.1.10
#tool nuget:?package=CodeWF.Toolkit.Logging&version=1.1.10
CodeWF.Toolkit.Logging
轻量级日志核心库:控制台输出、文件轮转日志与 UI 日志事件,适合控制台、桌面等 .NET 应用统一接入日志能力。Lightweight logging core with console output, rotating file logs and UI log events.
安装
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 | Versions 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. |
-
net10.0
- CodeWF.Toolkit.Lang (>= 1.1.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 11.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 11.0.0)
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 |