oceanSimple.OLog
1.0.0
dotnet add package oceanSimple.OLog --version 1.0.0
NuGet\Install-Package oceanSimple.OLog -Version 1.0.0
<PackageReference Include="oceanSimple.OLog" Version="1.0.0" />
<PackageVersion Include="oceanSimple.OLog" Version="1.0.0" />
<PackageReference Include="oceanSimple.OLog" />
paket add oceanSimple.OLog --version 1.0.0
#r "nuget: oceanSimple.OLog, 1.0.0"
#:package oceanSimple.OLog@1.0.0
#addin nuget:?package=oceanSimple.OLog&version=1.0.0
#tool nuget:?package=oceanSimple.OLog&version=1.0.0
Getting started
Prerequisites
Olog requires c# version .net 8 or above.
Getting Olog
With C#'s nuget support, you can get Olog with:
dotnet add package oceanSimple.OLog --version 1.0.0
Running Olog
A basic example:
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"));
Result as follows:
[2025-06-11 15:38:33] [INFO] Info test
[2025-06-11 15:38:33] [DEBUG] Debug test
[2025-06-11 15:38:33] [ERROR] Error test
[2025-06-11 15:38:33] [WARN] Warn test
LogBuilder
At
Getting started, we introduce the basic use about LogBuilder. Then we will introducetime format muduleandconsole color module
time format
You can use method SetTimeFormat to set a suitable time format in your project.
A basic example:
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"));
Result as follows:
[2025-04-14] [INFO] Info test
[2025-04-14] [DEBUG] Debug test
[2025-04-14] [ERROR] Error test
[2025-04-14] [WARN] Warn test
console color
If you want to print log at the console, then you may use ConsoleLogBuilder to print log with colorful prefix.
The core methode is the same as LogBuilder.
LogFileBuilder
If you want to save log in files, then you can use LogFileBuilder.
example
A basic example:
using OLog.Builders;
using OLog.Enums;
var logBuilder = new LogFileBuilder();
logBuilder.Info("Info test");
logBuilder.Debug("Debug test");
logBuilder.Error("Error test");
logBuilder.Warn("Warn test");
Then you can find a dictionary olog and a log file log.txt at the running dictionary.
For example, at this repository's test project, you will find the log file at OLogCsharp\OLogMain\bin\Debug\net8.0\olog\log.txt
settings
You can change the default configuration according to your own needs.
- Strategy: log persistence strategy. More on this in the next chapter.
- CacheLength: the log memory cache length.
- FilePath: log file name.
- LogBuilder: set a logBuilder which implements
ILogBuilder
Examples:
var logBuilder = new LogFileBuilder()
.SetStrategy(EStrategy.Always)
.SetCacheLength(20)
.SetFilePath("log.txt")
.SetLogBuilder(new LogBuilder());
cache persistence strategy
We support 3 strategies in EStrategy.
- Always: write every log into file.
- EveryN: it will save the logs in memory cache. when the length > N, flush all logs into file.
- Never: save all logs in memory cache. only when use
Flushmethod, will write logs into file.
| 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. |
-
net8.0
- No dependencies.
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 |
|---|---|---|
| 1.0.0 | 360 | 6/11/2025 |