P42.Serilog.QuickLog
1.0.3
See the version list below for details.
dotnet add package P42.Serilog.QuickLog --version 1.0.3
NuGet\Install-Package P42.Serilog.QuickLog -Version 1.0.3
<PackageReference Include="P42.Serilog.QuickLog" Version="1.0.3" />
paket add P42.Serilog.QuickLog --version 1.0.3
#r "nuget: P42.Serilog.QuickLog, 1.0.3"
// Install P42.Serilog.QuickLog as a Cake Addin #addin nuget:?package=P42.Serilog.QuickLog&version=1.0.3 // Install P42.Serilog.QuickLog as a Cake Tool #tool nuget:?package=P42.Serilog.QuickLog&version=1.0.3
P42.Serilog.QuickLog
Two goals:
Make it easy to log very common events by having event pre-populated with the following information:
- Caller class (required parameter)
- Caller method name (automatically generated)
- Exception Message and Inner Messages, with StackTrace (optional parameter)
- Message (optional parameter)
- Caller line number (optional and automatic)
Fire events just for these quick logged events that can be subscribed to by your code for handling.
Usage
MyClass.cs
using P42.Serilog.QuickLog;
namespace MyApp
{
public class MyClass
{
public void MyMethod()
{
try
{
throw new InvalidTimeZoneException("Bonkers!");
}
catch (Exception ex)
{
QLog.Error(this, ex);
}
}
}
}
Program.cs
using P42.Serilog.QuickLog;
using System;
namespace MyApp // Note: actual namespace depends on the project name.
{
internal class Program
{
static void Main(string[] args)
{
QLog.Logged += OnLogged;
var x = new MyClass();
x.MyMethod();
}
private static void OnLogged(object? sender, QLogEventArgs e)
{
Console.WriteLine(e);
}
}
}
Resulting log message:
ERROR: MyApp.MyClass.MyMethod[16] :
EXCEPTION: System.InvalidTimeZoneException Bonkers! :
at MyApp.MyClass.MyMethod() in C:\Users\ben\Development\SeriLogExtensions\P42.Serilog.QuickLog.Demo\MyClass.cs:line 12
Options
Serialize exceptions to JSON
Set which log levels will serialize exceptions as JSON (instead of pretty print) by setting P42.Serilog.QuickLog.QLog.SerializeExceptionsToJson
to the P42.Serilog.QuickLog.LogLevel
(s) desired. Example:
using P42.Serilog.QuickLog;
...
QLog.SerializeExceptionsToJson = LogLevel.Fatal | LogLevel.Error;
Add Line Number
Sometime iOS and Android release builds don't do the best job capturing line numbers. This doesn't fix that but at least it allows you to add line numbers. Set P42.Serilog.QuickLog.AddLineNumber
to the P42.Serilog.QuickLog.LogLevel
(s) desired. Example:
using P42.Serilog.QuickLog;
...
QLog.AddLineNumber = LogLevel.Fatal | LogLevel.Error;
Silent Logging
To control which LogLevels
(Verbose, Debug, Information, Warning, Error, Fatal) will NOT be passed along to the QLog.Logged
event. By default this is LogLevels.Verbose | LogLevels.Debug
.
Product | Versions 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 is compatible. 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. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.2)
- P42.NotifiableObject (>= 1.0.2)
- Serilog (>= 2.12.0)
-
net6.0
- Newtonsoft.Json (>= 13.0.2)
- P42.NotifiableObject (>= 1.0.2)
- Serilog (>= 2.12.0)
-
net7.0
- Newtonsoft.Json (>= 13.0.2)
- P42.NotifiableObject (>= 1.0.2)
- Serilog (>= 2.12.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on P42.Serilog.QuickLog:
Package | Downloads |
---|---|
P42.Utils
CrossPlatform Utilities |
|
P42.Uno.HtmlExtensions
Widgets for UNO Platform Applications |
|
P42.Uno.HtmlExtensions.Wasm
Widgets for UNO Platform Applications |
|
P42.Uno.HardwareKeys
Enabled hardware key input for Uno platform applications |
|
P42.Uno.HardwareKeys.Wasm
Enabled hardware key input for Uno platform applications |
GitHub repositories
This package is not used by any popular GitHub repositories.
Inital Public Release