Popularity
1.3
Stable
Activity
5.0
-
13
2
5

Description

Writes Serilog events to Excel-DNA LogDisplay.

Programming language: C#
License: Apache License 2.0
Tags: Logging     Excel     Serilog     Exceldna    
Latest version: v1.1.2

Serilog.Sinks.ExcelDnaLogDisplay alternatives and similar packages

Based on the "Logging" category.
Alternatively, view Serilog.Sinks.ExcelDnaLogDisplay alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Serilog.Sinks.ExcelDnaLogDisplay or a related project?

Add another 'Logging' Package

README

README.md

Serilog.Sinks.ExcelDnaLogDisplay

Writes Serilog events to Excel-DNA LogDisplay.

NuGet Version Stack Overflow Stack Overflow

[Excel-DNA LogDisplay window screenshot](assets/exceldna-logdisplay-window.png)

Give a Star! :star:

If you like or are using this project please give it a star. Thanks!

Getting started :rocket:

Install the Serilog.Sinks.ExcelDnaLogDisplay package from NuGet:

Install-Package Serilog.Sinks.ExcelDnaLogDisplay

To configure the sink in C# code, call WriteTo.ExcelDnaLogDisplay() during logger configuration:

var log = new LoggerConfiguration()
    .WriteTo.ExcelDnaLogDisplay(displayOrder: DisplayOrder.NewestFirst)
    .CreateLogger();

Example of an Excel-DNA add-in using Serilog with this sink

In the [sample](sample/) folder, there's an example of an Excel-DNA add-in that uses Serilog for logging to the LogDisplay of Excel-DNA using this sink, from different contexts, suchs as from an ExcelRibbon control event handler as well from an ExcelFunction:

[[Excel-DNA LogDisplay sample add-in ribbon screenshot](assets/sample-addin-ribbon.png)](sample/SampleAddIn/Ribbon.cs)

[[Excel-DNA LogDisplay sample add-in Excel function screenshot](assets/sample-addin-function.png)](sample/SampleAddIn/Functions.cs)

XML <appSettings> configuration

To use the Excel-DNA LogDisplay sink with the Serilog.Settings.AppSettings package, first install that package if you haven't already done so:

Install-Package Serilog.Settings.AppSettings

Instead of configuring the logger in code, call ReadFrom.AppSettings():

var log = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .CreateLogger();

In your Excel-DNA Add-In's App.config, specify the Excel-DNA LogDisplay sink assembly under the <appSettings> node:

<configuration>
  <appSettings>
    <add key="serilog:using:ExcelDnaLogDisplay" value="Serilog.Sinks.ExcelDnaLogDisplay" />
    <add key="serilog:write-to:ExcelDnaLogDisplay" />

The parameters that can be set through the serilog:write-to:ExcelDnaLogDisplay keys are the method parameters accepted by the WriteTo.ExcelDnaLogDisplay() configuration method. This means, for example, that the displayOrder parameter can be set with:

    <add key="serilog:write-to:ExcelDnaLogDisplay.displayOrder" value="NewestFirst" />

Controlling event formatting

The Excel-DNA LogDisplay sink creates events in a fixed text format by default:

2021-09-07 09:02:17.148 -03:00 [INF] HTTP GET / responded 200 in 1994 ms

The format is controlled using an output template, which the Excel-DNA LogDisplay sink configuration method accepts as an outputTemplate parameter.

The default format above corresponds to an output template like:

  .WriteTo.ExcelDnaLogDisplay(
    outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}")
JSON event formatting

To write events to the Excel-DNA LogDisplay in an alternative format such as JSON, pass an ITextFormatter as the first argument:

    // Install-Package Serilog.Formatting.Compact
    .WriteTo.ExcelDnaLogDisplay(new CompactJsonFormatter())

Auditing

The Excel-DNA LogDisplay sink can operate as an audit sink through AuditTo:

    .AuditTo.ExcelDnaLogDisplay(displayOrder: DisplayOrder.NewestFirst)

Excel-DNA configuration for packing with ExcelDnaPack

In order for the Excel-DNA LogDisplay sink to work from an add-in that was packaged using the ExcelDnaPack utility, you need to include references to Serilog.dll and Serilog.Sinks.ExcelDnaLogDisplay.dll in the .dna file of the add-in:

<DnaLibrary Name="My Add-In" RuntimeVersion="v4.0">
  <ExternalLibrary Path="MyAddIn.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" />

  <Reference Path="Serilog.dll" Pack="true" />
  <Reference Path="Serilog.Sinks.ExcelDnaLogDisplay.dll" Pack="true" />

Release History

Click on the Releases tab on GitHub.


Copyright © 2018-2021 C. Augusto Proiete & Contributors - Provided under the [Apache License, Version 2.0](LICENSE).


*Note that all licence references and agreements mentioned in the Serilog.Sinks.ExcelDnaLogDisplay README section above are relevant to that project's source code only.