OLog 1.0.0
dotnet add package OLog --version 1.0.0
NuGet\Install-Package OLog -Version 1.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="OLog" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OLog" Version="1.0.0" />
<PackageReference Include="OLog" />
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 OLog --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: OLog, 1.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 OLog@1.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=OLog&version=1.0.0
#tool nuget:?package=OLog&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
♾️项目介绍
使用 c# 语言实现的日志库. 包含日志字符串生成器以及日志文件写入器
♾️构造器介绍
💫LogBuilder
默认构造器
using OLog.Builders;
var logBuilder = new LogBuilder();
Console.WriteLine(logBuilder.Info("Info test"));
Console.WriteLine(logBuilder.Debug("Debug test"));
Console.WriteLine(logBuilder.Error("Error test"));
Console.WriteLine(logBuilder.Warn("Warn test"));
[2025-04-14 20:42:09] [INFO] Info test
[2025-04-14 20:42:09] [DEBUG] Debug test
[2025-04-14 20:42:09] [ERROR] Error test
[2025-04-14 20:42:09] [WARN] Warn test
修改 time 格式
using OLog.Builders;
var logBuilder = new LogBuilder();
logBuilder.SetTimeFormat("yyyy-MM-dd");
Console.WriteLine(logBuilder.Info("Info test"));
Console.WriteLine(logBuilder.Debug("Debug test"));
Console.WriteLine(logBuilder.Error("Error test"));
Console.WriteLine(logBuilder.Warn("Warn test"));
[2025-04-14] [INFO] Info test
[2025-04-14] [DEBUG] Debug test
[2025-04-14] [ERROR] Error test
[2025-04-14] [WARN] Warn test
💫ConsoleLogBuilder
控制台日志生成器: Info, Default 等日志类别字符, 在控制台显示时自带颜色 使用方法同 LogBuilder
💫LogFileBuilder
日志文件写入构造器, 将日志写入磁盘文件
- 文件目录: 当前运行的文件夹下, 创建一个
olog文件夹 - 日志文件: 默认文件为
log.txt
using OLog.Builders;
using OLog.Enums;
var logBuilder = new LogFileBuilder()
.SetStrategy(EStrategy.Always)
.SetCacheLength(20)
.SetFilePath("log1.txt")
.SetLogBuilder(new LogBuilder());
logBuilder.Info("Info test");
logBuilder.Debug("Debug test");
logBuilder.Error("Error test");
logBuilder.Warn("Warn test");
写入策略
- Always: 自动写入磁盘
- EveryN: 先将日志写入缓存中, 当缓存数超过 N 时, 全部flush到磁盘
- Never: 日志全部写入缓存中, 当且仅当用户主动调用flush函数时, 才将日志写入磁盘
| Product | Versions 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.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OLog:
| Package | Downloads |
|---|---|
|
oceanSimple.OWsCommon
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 322 | 4/15/2025 |