C1.Logger 1.0.2

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

C1Logger

My Website: Corpi1.uk

C1Log is a modern, thread-safe, and highly configurable logging library for .NET applications.
It supports asynchronous logging, file rolling (by date and size), minimum log level filtering, syslog-style log levels (with shorthand), and custom log sinks for advanced scenarios.


Installation

To use this library, install it via NuGet in your project. You can do this by running the following command in the Package Manager Console:

Latest Version:

NuGet\Install-Package C1.Logger

Specific Version:

NuGet\Install-Package C1.Logger --Version x.x.x

Alternatively, search for "C1Log" in the NuGet Package Manager in Visual Studio and install it from there.


Usage

For a full usage guide, please refer to the Docs

Note:
C1Log is fully self-initializing. You do not need to call any initialization method.
If you want to customize configuration (log directory, minimum log level, formatter, etc.), set those properties before your first log call.

Log Levels:

  • Emergency (emerg)
  • Alert (alert)
  • Critical (crit)
  • Error (error)
  • Warning (warn)
  • Notice (notice)
  • Informational (info)
  • Debug (debug)

Basic Examples:

Default usage with default settings:

using C1Logger; 
C1Log.Info("Application started."); 
C1Log.Flush(); // Ensure all logs are written

Customizing the log directory, log level and format:

using C1Logger; 
C1Log.LogDirectory = @"C:\Logs"; // Specify your log directory 
C1Log.MinLogLevel = C1Log.LogLevel.Warning; // Set minimum log level to Warning 
C1Log.Formatter = (dt, lvl, msg) => $"[{lvl.ShortHand()}] {dt:HH:mm:ss} - {msg}"; // Custom log message to use shorthand
C1Log.Info("Application started."); 
C1Log.Error("An error occurred."); 
C1Log.Flush(); // Ensure all logs are written

Full API Example:

using System; 
using C1Logger;
public class MyCustomSink : C1Log.ILogSink {
    public C1Log.LogLevel MinLogLevel => C1Log.LogLevel.Notice; 
    public void Dispose() { } 
    public Task WriteAsync(string message, 
    C1Log.LogLevel level, IDictionary<string, object> context = null) {
        // Custom sink logic here 
        return Task.CompletedTask; 
        } 
    }
class Program { 
    static void Main() { 
        // Configure logger before first log
        C1Log.LogDirectory = @"C:\Logs"; 
        C1Log.MinLogLevel = C1Log.LogLevel.Notice; 
        C1Log.Formatter = (dt, lvl, msg) => $"[{lvl.ShortHand()}] {dt:HH:mm:ss} - {msg}"; 
        C1Log.AddSink(new MyCustomSink());
        // Subscribe to logging failures
        C1Log.OnLoggingFailure += ex => Console.Error.WriteLine($"Logging failed: {ex}");

        // Log messages
        C1Log.Info("Informational message.");
        C1Log.Warning("Warning message.");
        C1Log.Error("Error message.");
        C1Log.Exception(new Exception("Test exception"));
        C1Log.Flush(); // Ensure all logs are written
    }
}

Building

If you want to build the project yourself, follow these steps:

  1. Install Visual Studio (Community Edition is sufficient).
    • Select the .NET desktop development workload during installation.
  2. Clone the repository to your local machine using Git or download it as a ZIP file.
  3. Open the folder in Visual Studio as a new project.
  4. Build the project by selecting Build > Build Solution or pressing Ctrl + Shift + B.
    • This should install all required dependencies. If not, manually install them via Manage NuGet Packages.
  5. Once the build completes, you can run it:
    1. From Visual Studio: Debug > Start Debugging or F5
    2. From the built executable in \bin\Debug\net8.0 (or Release for release builds).

License

This project is licensed under the Corpi1 Software License (Based on Mozilla Public License 2.0).

You are free to use, modify, and distribute the software. Businesses and individuals can use it, including in commercial activities. However, you may not sell, repackage, or monetize the software itself.

See the LICENSE file for full terms.

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.2 149 6/30/2025
1.0.1 144 6/24/2025
1.0.0 143 6/24/2025

Initial