Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Version 3.0.0

Compare
Choose a tag to compare
@AnthonySteele AnthonySteele released this 09 Feb 14:58
· 20 commits to master since this release
f1e69db

NLog.StructuredLogging.Json version 3.0.0 is released.

This is a major version release because of the change in #118 which breaks binary compatibility.
Existing code should still work as before, after recompiling with NLog.StructuredLogging.Json version 3.0.0.

This release is not a return to full active development of this library, as this is unnecessary. It is maintenance to make sure that it keeps working as well as before, and supports a new scenario.

Allow default null for extended data

Pull Request #118

Standard usage is e.g. _logger.ExtendedInfo("Order placed", new { OrderId = 1234 });

But if you have no properties to add, you use an empty properties object: _logger.ExtendedInfo("Order placed", new { }); or a null: _logger.ExtendedInfo("Order placed", null); .

This change also allows _logger.ExtendedInfo("Order placed"); as there is a default value of null for the properties.

Compatibility with the ILogger abstraction

Pull Request #126

Compatibility with the ILogger abstraction in Microsoft.Extensions.Logging.Abstractions and message templates used therein.

This is useful if you use libraries that need an ILogger implementation (such as JustSaying V6) and want the output to go to structured JSON files.

How to ensure that you can use ILogger with this library's JSON formatted output:

ILogger example

When _logger is an ILogger instance set up as above, and the code is:

_logger.LogInformation("Templated information for order {OrderId} at {CustomProperty}",  
    12345, DateTime.UtcNow);

The log entry will be like this:

{
  "TimeStamp":"2019-01-29T11:12:46.609Z",
  "Level":"Info",
  "LoggerName":"LogDemo.HomeController",
  "Message":"Templated information for order 12345 at 01/29/2019 11:12:46",
  "MessageTemplate":"Templated information for order {OrderId} at {CustomProperty}",
  "OrderId": 12345,
  "CustomProperty":"2019-01-29T11:12:46.6210834Z"
}