SimpleLog4.NET 2.3.0.18

dotnet add package SimpleLog4.NET --version 2.3.0.18
NuGet\Install-Package SimpleLog4.NET -Version 2.3.0.18
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="SimpleLog4.NET" Version="2.3.0.18" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleLog4.NET --version 2.3.0.18
#r "nuget: SimpleLog4.NET, 2.3.0.18"
#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.
// Install SimpleLog4.NET as a Cake Addin
#addin nuget:?package=SimpleLog4.NET&version=2.3.0.18

// Install SimpleLog4.NET as a Cake Tool
#tool nuget:?package=SimpleLog4.NET&version=2.3.0.18

SimpleLog4.NET - Log All The Things

Fast Non-Blocking Zero Allocation Thread Safe Logger for .NET Standard and Greater

All formatting and logging is done in a different thread.


Creating a Simple Log

using SimpleLog4.NET;

Create a new SimpleLog with SimpleLogLevel.Information

SimpleLog Log = new SimpleLog(@"C:\test.txt", logLevel: SimpleLogLevel.Information);

Create a new SimpleLog with SimpleLogLevel.Error that also logs to Console

SimpleLog Log = new SimpleLog(@"C:\loglevelError.txt", true);

Create a new SimpleLog and change the DateFormat

SimpleLog Log = new SimpleLog(@"C:\test.txt", dateFormat: "MM/dd/yyyy HH:mm:ss:fff");

Create a new SimpleLog and change the IFormatProvider

SimpleLog Log = new SimpleLog(@"C:\test.txt", formatProvider: CultureInfo.InvariantCulture);

Write to the Log

Messages

You should always provide the unformatted message to the logging methods

Log.Information("Some Information"); 
// [05/06/24 18:19:19:170][Info] Some Information

Log.Trace();
Log.Debug();
Log.Warning();
Log.Error();
Log.Critical();
Log.Fatal();

Exceptions

Exceptions are specially formatted automatically

Log.Exception(exception); // Exception
// [05/06/24 17:00:27:383][Exception]
// System.ArgumentException | HRESULT: -2147024809
// Message: Invalid Argument
// Stack Trace: 
//    at TestApp.MainContext.TestAll() in C:\Project\Base\MainContext.cs:line 72

WriteExceptionDirect can be used to log Exceptions inside Unhandled Exception Handlers

Log.WriteExceptionDirect(exception); // Skips Queue

More Output Examples

Below are more examples of what the output should look like in a text file

Normal Output
[05/06/24 18:19:19:170][Info] Updated Exchange Information for [2617] symbols
[05/06/24 18:19:19:170][Info] Loaded [11] Stored Quotes from file
[05/06/24 18:19:19:170][Info] Loaded [0] Alerts from file
[05/06/24 18:19:19:372][Info] Loaded [405] Orders from file
[05/06/24 18:19:19:950][Info] Loaded [5782] Orders from file
[05/06/24 18:19:20:090][Info] Loaded [555] Orders from file
[05/06/24 18:19:20:090][Info] Loaded [71] Orders from file
[05/06/24 18:19:20:108][Info] Loaded [16] Orders from file
[05/06/24 18:19:20:123][Info] Got new Exchange Information from Server..
[05/06/24 18:19:20:123][Info] Updated Exchange Information for [2617] symbols

Single Exception
[05/06/24 17:00:27:383][Critical] Test Critical
[05/06/24 17:00:27:383][Exception]
System.ArgumentException | HRESULT: -2147024809
Message: Invalid Argument
Stack Trace: 
   at TestApp.MainContext.TestAll() in C:\Project\Base\MainContext.cs:line 72
[05/06/24 17:00:27:383][FATAL] Test Fatal

Aggregate Exception
[05/06/24 17:00:27:383][Critical] Test Critical
[05/06/24 17:00:27:383][Exception]
System.AggregateException | HRESULT: -2146233088
Message: One or more errors occurred.
Stack Trace: 
   at TestApp.MainContext.TestAll() in C:\Project\Base\MainContext.cs:line 99
--------
System.ArgumentException | HRESULT: -2147024809
Message: Invalid Argument
Stack Trace: 
   at TestApp.MainContext.TestAll() in C:\Project\Base\MainContext.cs:line 72
--------
System.ArgumentOutOfRangeException | HRESULT: -2146233086
Message: Count Must be greater than 5
Parameter name: exampleField
Stack Trace: 
   at TestApp.MainContext.TestAll() in C:\Project\Base\MainContext.cs:line 81
--------
System.ArgumentNullException | HRESULT: -2147467261
Message: Count can not be null
Parameter name: exampleField
Stack Trace: 
   at TestApp.MainContext.TestAll() in C:\Project\Base\MainContext.cs:line 90
--------
[05/06/24 17:00:27:383][FATAL] Test Fatal

alternate text is missing from this package README image alternate text is missing from this package README image

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.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.

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
2.3.0.18 36 5/6/2024

Add support for IFormatProvider

The default IFormatProvider is CultureInfo.InvariantCulture

Improve Exception Handling

Embedded symbols

Optimizations

-----------------
Please use the most recent version visible on Nuget, old versions are hidden but can still be downloaded indirectly