oceanSimple.OLog 1.0.0

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

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 introduce time format mudule and console 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 Flush method, will write logs into file.
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.
  • 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