Home
Softono
Sherlog

Sherlog

Open source MIT C#
191
Stars
36
Forks
1
Issues
18
Watchers
3 years
Last Commit

About Sherlog

Sherlog is a lightweight logging library for C and Unity, focused on speed, flexibility, and extensibility. It supports local and remote logging out of the box, enabling over-the-air log message reception from other devices. The library includes six log levels (Trace, Debug, Info, Warn, Error, and Fatal) and offers modular packages for appenders and formatters separately. It is available via NuGet for .NET projects and OpenUPM for Unity, with automated Unity package releases. Sample projects demonstrate console logging, colors, timestamps, and TCP-based remote logging. The library is MIT-licensed and designed to be easily extended for custom logging workflows.

Platforms

Web Self-hosted Windows

Languages

C#

Links

Sherlog-Header

Sherlog – Flexible logging for C# and Unity

Sherlog is a very light logging library with a clear focus on speed, flexibility, and extensibility. It supports local and remote logging out of the box so you can receive log messages from other devices over the air.

CI Coverage Status NuGet License: MIT Twitter

Install

NuGet Unity Packages on OpenUPM
Sherlog NuGet openupm
Sherlog.Appenders NuGet openupm
Sherlog.Formatters NuGet openupm

Automated Unity Package Releases: https://github.com/sschmid/com.sschmid.sherlog

Quick Start

The SherlogSamples project contains samples for different use cases, such as logging to the console, adding colors or timestamps, and sending log messages via TCP to other devices.

See SherlogSamples

dotnet run --project samples/SherlogSamples/SherlogSamples.csproj

Run the SherlogServer project to receive the sample log messages from SherlogSamples via a TCP connection.

See SherlogServer

dotnet run --project samples/SherlogServer/SherlogServer.csproj listen 12345

SherlogSamples

Sherlog terminology

LogLevel

There are 6 log levels matching the Sherlog log methods:

logger.Trace("This is a message using logger.Trace()");
logger.Debug("This is a message using logger.Debug()");
logger.Info("This is a message using logger.Info()");
logger.Warn("This is a message using logger.Warn()");
logger.Error("This is a message using logger.Error()");
logger.Fatal("This is a message using logger.Fatal()");

You can set the log level per logger or globally for all existing and future loggers.

Logger.GlobalLogLevel = LogLevel.Warn;
var logger = Logger.GetLogger("MyLogger");
logger.LogLevel = LogLevel.Debug;

Only log methods that match or exceed the current log level will forward messages to appenders.

Appenders

Sherlog's plugin architecture lets you add multiple different appenders to handle log messages. An appender is a delegate method which contains the logic for processing log messages. It might write a message to a file, print it to the console or send it over the network via TCP. You can easily write your own appenders. There are no limits!

Sherlog comes with a handful of pre-made appenders and helper classes to get you started quickly:

see Sherlog.Appenders

Formatters

Similar to appenders you can add formatters to decorate messages with additional info like logger name, log level, timestamp, or color.

see Sherlog.Formatters

Maintainer(s)

@sschmid on GitHub - @s_schmid on Twitter