Mash.Logging 1.0.2-preview

Provides logging abstraction and multi-destination routing.

This is a prerelease version of Mash.Logging.
Install-Package Mash.Logging -Version 1.0.2-preview
dotnet add package Mash.Logging --version 1.0.2-preview
<PackageReference Include="Mash.Logging" Version="1.0.2-preview" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mash.Logging --version 1.0.2-preview
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Mash.Logging, 1.0.2-preview"
For F# scripts that support #r syntax, copy this into the source code to reference the package.

Mash.Logging

Most of my code starts running locally in a console window, so I want logs printed to the screen.
Soon that code begins running headless, and I rely on logs to know what happened after the fact.
I don't want to change my logging up, I just want it to go to a different location.
Sometimes, I want it to go to multiple locations.

This utility allows you to configure logging providers, and build loggers from that to hand off to business logic.
It also lets you specify a common property bag of data to be automatically included with each log statement.
Additionally, each logger instance can build its own context.

Initialization

To initialize logging:

var loggingBuilder = new LoggingBuilder();

// Add any app-level contextual properties
loggingBuilder.AppContext.Add("RunId", Guid.NewGuid().ToString());

// Add desired providers
loggingBuilder.LogProviders.Add(new ConsoleLogProvider());

var logger = loggingBuilder.BuildLogger(
    new Dictionary<string, string>
    {
        { "Operation", "ProcessOrders" },
    });

// Now pass off your logger to code to do work
ProcessOrders(logger);

Logging

Logging is simple.
Code can log traces, metrics, or events.
See this sample for examples.

If an operation branches off into more than one code path, you can clone the current logger which copies the current logger context into the new logger.
Modifications to that logger's context will not affect the current one.

Logging providers

This utility includes a console logger, and you can build your own adapters to other destinations.

Changelog

2020/09/12 - 1.0.2-preview

Fixed bug where ConsoleLogProvider.ShouldLogContext was ignored.

Mash.Logging

Most of my code starts running locally in a console window, so I want logs printed to the screen.
Soon that code begins running headless, and I rely on logs to know what happened after the fact.
I don't want to change my logging up, I just want it to go to a different location.
Sometimes, I want it to go to multiple locations.

This utility allows you to configure logging providers, and build loggers from that to hand off to business logic.
It also lets you specify a common property bag of data to be automatically included with each log statement.
Additionally, each logger instance can build its own context.

Initialization

To initialize logging:

var loggingBuilder = new LoggingBuilder();

// Add any app-level contextual properties
loggingBuilder.AppContext.Add("RunId", Guid.NewGuid().ToString());

// Add desired providers
loggingBuilder.LogProviders.Add(new ConsoleLogProvider());

var logger = loggingBuilder.BuildLogger(
    new Dictionary<string, string>
    {
        { "Operation", "ProcessOrders" },
    });

// Now pass off your logger to code to do work
ProcessOrders(logger);

Logging

Logging is simple.
Code can log traces, metrics, or events.
See this sample for examples.

If an operation branches off into more than one code path, you can clone the current logger which copies the current logger context into the new logger.
Modifications to that logger's context will not affect the current one.

Logging providers

This utility includes a console logger, and you can build your own adapters to other destinations.

Changelog

2020/09/12 - 1.0.2-preview

Fixed bug where ConsoleLogProvider.ShouldLogContext was ignored.

Release Notes

Initial release.

  • .NETStandard 1.3

  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Mash.Logging:

Package Downloads
Mash.Logging.ApplicationInsights
Provides a logging abstraction for Azure Application Insights.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.2-preview 120 9/12/2020
1.0.1-preview 158 8/18/2020
1.0.0-preview 147 8/17/2020