SimpleLogs4Net

Simple Logs Library for .Net

View on GitHub

Initialization

First of all you need to add using the namespace

using SimpleLogs4Net;
// this line is needed to use log

Then you need to

new LogConfiguration("Logs\\",OutputStream.Both);
// using this line you can initialize Logs

Output Stream can be changed on runtime

LogConfiguration.ChangeOutputStream(OutputStream.None);
LogConfiguration.ChangeOutputStream(OutputStream.Console);
LogConfiguration.ChangeOutputStream(OutputStream.File);
LogConfiguration.ChangeOutputStream(OutputStream.Both);

Usage

You can add an event using Log.AddEvent

Log.AddEvent(new Event("text", EType.Normal));

Adding events

Log.Write("Test");
// event will be set to Default Type whitch is EType.Normal
// Default Type can be changed using line below
LogConfiguration.ChangeDefaultType(EType.Information);
Log.Write("Test", EType.Normal);
Log.Write("Test", EType.Informtion);
Log.Write("Test", EType.Warning);
Log.Write("Test", EType.Error);
// Sample Output:
//[07.04.2023-10:20:47][NORMAL]Program: Test
//[07.04.2023-10:20:47][NORMAL]Program: Test
//[07.04.2023-10:20:47][INFO]Program: Test
//[07.04.2023-10:20:47][WARNING]Program: Test
//[07.04.2023-10:20:47][ERROR]Program: Test

To make new log You Can Use NextLog

Log.NextLog();

multiline output

string[] multiline = ...;
Log.AddEvent(new Event(multilinestring, EType.Normal));

SimpleLogs4Net includes a simple way to delete all log files

Log.ClearLogs();

Added DebugMsg

Log.DebugMsg("info");
Log.DebugMsg("ok", EType.Normal);
// Debug messages are qued until the first log write or if is initialized will be written imietly 

Deprication

Using the Log.AddEvent is goeing to be depricated in folowig section If possible use latest version of 3.* versions as some older versions have really embarasing programmer errors