EasyLogPlus 1.0.6.1

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

EasyLogPlus

A [relatively] simple .NET 6 logging library. Originally made by byte-0x74, extended by asoji. image

What's different between this and the original repo?

  • Uses .NET 6 instead of .NET Framework 4.x
  • The text is more way readable [in my opinion]*
  • Customizable severity level colors
  • Added the whole Syslog Severity Level standardization [read about that here], cranking from 4 severity levels to 8.
  • Uses your local timezone in logs instead of UTC timezone
  • Switchable between : and => in logs, like NOTICE: This is notice text! or NOTICE => This is notice text! using cfg.UseColon
  • Ability to have Critical-Emergency logs be logged in a seperate file through cfg.SeperateCriticalLogs
  • Probably a lot of breaking changes, but I plan on basically keeping this seperate from the original project.

Basically, I should've just made my own logger considering how much I changed, but eh, this fork works, and I'm pretty happy with it.

*- This is what the original looked like on my screen in Rider and oh no.

ohno

It looks a lot better like this now

ohyes

How to use?

Installation

You have 2 ways:

  • [as of 1.0.6.1], you can now just grab EasyLogPlus from NuGet, or dotnet add package EasyLogPlus
  • Install EasyLogPlus from GitHub's NuGet Registry, instructions here, make sure the author is asoji

Usage

  • Add using EasyLogPlus; to the top, and then add
Logger log = new Logger();
Config cfg = new Config();

Customization Options

If you want customize settings add these, keeping in mind that this whole SetConfig() is optional, and not required to run the application.

void SetConfig()
{
    cfg.ShowDate = true; // If this is set to true, it will add date to the log
    cfg.Console = true; // If this is set to true, it will print the log to Console too
    cfg.SeperateCriticalLogs = true; // If this is set to true, it will print Critical-Emergency logs to a seperate log file

    // ENTIRELY optional, just add and change if you want.
    cfg.UseColon = true; // If set to true, uses `:` in logs instead of `=>`

    cfg.LogPath = Environment.CurrentDirectory + $@"\Application.log"; // Sets where your Log saves and under what name

    // Logger color customization
    cfg.DebugText = ConsoleColor.Blue;
    cfg.InfoText = System.Console.ForegroundColor;
    cfg.NoticeText = ConsoleColor.Green;
    cfg.WarningText = ConsoleColor.DarkYellow;
    cfg.ErrorText = ConsoleColor.Red;
    cfg.CriticalText = ConsoleColor.White;
    cfg.AlertText = ConsoleColor.White;
    cfg.EmergencyText = ConsoleColor.White;

    cfg.DebugBackground = System.Console.BackgroundColor;
    cfg.InfoBackground = System.Console.BackgroundColor;
    cfg.NoticeBackground = System.Console.BackgroundColor;
    cfg.WarningBackground = System.Console.BackgroundColor;
    cfg.ErrorBackground = System.Console.BackgroundColor;
    cfg.CriticalBackground = ConsoleColor.DarkRed;
    cfg.AlertBackground = ConsoleColor.DarkBlue;
    cfg.EmergencyBackground = ConsoleColor.DarkMagenta;
}

Then in your application main void add these, this is required.

log.cfg = cfg;
SetConfig();
log.InitLogger(); // Call this to init logger

Using Logs

  • Debug Log
log.Debug("Hello from log, this is debug");
  • Info Log
log.Info("Hello from log, this is info");
  • Notice Log
log.Notice("Hello from log, this is notice");
  • Warning Log
log.Warning("Hello from log, this is warning");
  • Error Log
log.Error("Hello from log, this is error");
  • Critical Log
log.Critical("Hello from log, this is critical")
  • Alert Log
log.Alert("Hello from log, this is alert")
  • Emergency Log
log.Emergency("Hello from log, this is emergency")

[terrible] Example

class Program {
        static Logger log = new Logger();
        static Config cfg = new Config();
        
        static void SetConfig() {
            cfg.LogPath = Environment.CurrentDirectory + @"\Application.log";
            cfg.ShowDate = true;
            cfg.Console = true;
            cfg.SeperateCriticalLogs = true;

            cfg.UseColon = false;

            cfg.CriticalBackground = ConsoleColor.Cyan;
            cfg.NoticeText = ConsoleColor.Magenta;
        }

        static void Main(string[] args) {
            SetConfig();
            log.cfg = cfg;
            log.InitLogger();

            try {
                // do some random shit
            } catch (ArgumentOutOfRangeException outOfRangeException) {
                log.Critical("hey something is out of range?");
            }
            
            Console.ReadKey();
        }
    }

License

This project [well, fork] is MIT Licensed. Thank you byte-0x74/0x74 for making the original lib C:

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net6.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.6.1 275 9/4/2022