P42.Serilog.QuickLog 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package P42.Serilog.QuickLog --version 1.0.5                
NuGet\Install-Package P42.Serilog.QuickLog -Version 1.0.5                
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="P42.Serilog.QuickLog" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add P42.Serilog.QuickLog --version 1.0.5                
#r "nuget: P42.Serilog.QuickLog, 1.0.5"                
#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 P42.Serilog.QuickLog as a Cake Addin
#addin nuget:?package=P42.Serilog.QuickLog&version=1.0.5

// Install P42.Serilog.QuickLog as a Cake Tool
#tool nuget:?package=P42.Serilog.QuickLog&version=1.0.5                

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
1.0.9 164 1/17/2024
1.0.8 2,809 12/5/2023
1.0.7 125 11/21/2023
1.0.6 100 11/21/2023
1.0.5 149 8/14/2023
1.0.4 7,828 6/8/2023
1.0.3 135 5/18/2023
1.0.2 165 4/25/2023
1.0.1 184 3/28/2023
1.0.0 213 2/8/2023

Inital Public Release