VOOZH about

URL: https://www.nuget.org/packages/J4JSoftware.Logging/

⇱ NuGet Gallery | J4JSoftware.Logging 4.2.1




👁 Image
J4JSoftware.Logging 4.2.1

Suggested Alternatives

J4JSoftware.LoggingSerilog

Additional Details

I substantially redesigned the original J4JLogger package and extended it to include the Microsoft logging system as well.

dotnet add package J4JSoftware.Logging --version 4.2.1
 
 
NuGet\Install-Package J4JSoftware.Logging -Version 4.2.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="J4JSoftware.Logging" Version="4.2.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="J4JSoftware.Logging" Version="4.2.1" />
 
Directory.Packages.props
<PackageReference Include="J4JSoftware.Logging" />
 
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 J4JSoftware.Logging --version 4.2.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: J4JSoftware.Logging, 4.2.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.
#:package J4JSoftware.Logging@4.2.1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=J4JSoftware.Logging&version=4.2.1
 
Install as a Cake Addin
#tool nuget:?package=J4JSoftware.Logging&version=4.2.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

J4JLogging


As of 2023 April 4 I am no longer developing this library.

The reason is simple: I learned more about how Serilog works and realized there was a much easier way of implementing the same functionality 😃.

Take a look at J4JLoggerEnhancements for a new, slimmer approach for doing what J4JLogging does.


A Net library which wraps Serilog's ILogger and extends it by reporting source code information.

Licensed under GNU GPL-v3.0. See the for details.

👁 Nuget

TL;DR

using System;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using J4JSoftware.Logging;
using Microsoft.Extensions.Configuration;
using Serilog;

namespace ConfigurationBasedExample
{
 // shows how to use J4JLogger with a configuration file
 // see the ConfigurationBasedExample project for other files and details
 class Program
 {
 static void Main(string[] args)
 {
 var loggerConfig = new J4JLoggerConfiguration();

 var configRoot = new ConfigurationBuilder()
 .AddJsonFile( Path.Combine( Environment.CurrentDirectory, "appConfig.json" ), true )
 .Build();

 loggerConfig.SerilogConfiguration
 .ReadFrom
 .Configuration( configRoot );
 
 var logger = loggerConfig.CreateLogger();
 logger.SetLoggedType(typeof(Program));

 logger.Information("This is an Informational logging message");
 logger.Fatal("This is a Fatal logging message");
 }
 }
}

The console output looks like this:

The log file, log20210801.txt, looks like this:

2021-09-15 10:14:59.173 -07:00 [INF] This is an Informational logging message ConfigurationBasedExample.Program::Main (C:\Programming\J4JLogging\examples\ConfigurationBasedExample\Program.cs:32) 
2021-09-15 10:14:59.238 -07:00 [FTL] This is a Fatal logging message ConfigurationBasedExample.Program::Main (C:\Programming\J4JLogging\examples\ConfigurationBasedExample\Program.cs:33) 

Your log file's name will be different because, by default, the log file rolls daily and the last day logging took place will be embedded in the file name.

There is a simple way of trimming the logged source code file paths to make them relative to the project directory path. See for how to do this.

You can read about how to use the Serilog IConfiguration-based configuration system .

Important Note

There is one important difference in how you call the logging methods from the Serilog standard.

If you pass nothing but simple strings to the methods as property values you must specify the types of the propertyValue arguments explicitly in the method call.

An example:

string someStringValue = "abcd";
_logger.Debug<string>("The value of that argument is {0}", someStringValue);

This requirement comes about because the memberName, srcPath and srcLine arguments are automagically set for you by the compiler. The fact the memberName and srcPath arguments of the logging methods are strings makes them "collide" with string arguments you may specify. That makes explict type specifications for the arguments necessary when the compiler can't figure out what you mean...which is all too common 😃.

Table of Contents

Product Versions Compatible and additional computed target framework versions.
.NET net7.0 net7.0 is compatible.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on J4JSoftware.Logging:

Package Downloads
J4JSoftware.GeoProcessor

a library for processing GPX, KML and KMZ files, and snapping GPS tracks to roadways

J4JSoftware.Logging.Twilio

Extends the J4JLogger library to support SMS logging via Twilio

J4JSoftware.GeoProcessorApp

a console application for processing GPX, KML and KMZ files, and snapping GPS tracks to roadways

J4JSoftware.GeoProcessorWPF

a WPF application for processing GPX, KML and KMZ files, and snapping GPS tracks to roadways

J4JSoftware.WpFormsSurvey

utilities for exporting WPForms forms and survey responses to Excel (.xlsx) files

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.2.1 557 4/4/2023 4.2.1 is deprecated.
4.2.0 1,048 12/27/2022
4.1.2 1,053 2/28/2022
4.1.1 867 2/28/2022
4.1.0 1,123 11/12/2021
4.0.1 2,002 9/29/2021
4.0.0 2,149 9/28/2021
3.2.0 2,005 2/3/2021
3.1.0 1,401 1/21/2021
3.0.0 1,887 1/9/2021
2.5.1 947 6/30/2020
2.5.0 1,011 6/30/2020
1.0.0 756 6/30/2020

updated packages, announced end of development