|
1 | 1 | # Serilog.Enrichers.ExcelDna [](https://www.nuget.org/packages/Serilog.Enrichers.ExcelDna/) [](LICENSE)
|
2 | 2 |
|
| 3 | +Enriches [Serilog](https://serilog.net) events with information from your [Excel-DNA](https://excel-dna.net) Add-in. |
| 4 | + |
| 5 | +### Getting started |
| 6 | + |
| 7 | +Install the [Serilog.Enrichers.ExcelDna](https://www.nuget.org/packages/Serilog.Enrichers.ExcelDna/) package from NuGet: |
| 8 | + |
| 9 | +```powershell |
| 10 | +Install-Package Serilog.Enrichers.ExcelDna |
| 11 | +``` |
| 12 | + |
| 13 | +To apply the enricher to your logger configuration: |
| 14 | + |
| 15 | +```csharp |
| 16 | +var log = new LoggerConfiguration() |
| 17 | + .Enrich.WithXllPath() |
| 18 | + // ... other configuration ... |
| 19 | + .CreateLogger(); |
| 20 | +``` |
| 21 | + |
| 22 | +The `WithXllPath()` enricher will add an `XllPath` property to produced events. |
| 23 | + |
| 24 | +### Included enrichers |
| 25 | + |
| 26 | +The package includes: |
| 27 | + |
| 28 | +* `WithXllPath()` - adds `XllPath` based with the value of `ExcelDnaUtil.XllPath` |
| 29 | +* `WithExcelVersion()` - adds `ExcelVersion` with the value of `ExcelDnaUtil.ExcelVersion` |
| 30 | +* `WithExcelVersionName()` - adds `ExcelVersionName` based on `ExcelDnaUtil.ExcelVersion` |
| 31 | +* `WithExcelBitness()` - adds `ExcelBitness` based `Environment.Is64BitProcess` |
| 32 | + |
| 33 | +### Example of an Excel-DNA add-in using Serilog with this sink |
| 34 | + |
| 35 | +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, and apply the enrichers described above. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +### Excel-DNA configuration for packing with `ExcelDnaPack` |
| 40 | + |
| 41 | +In order for the Excel-DNA enricher to work from an add-in that was packaged using the `ExcelDnaPack` utility, you need to include references to `Serilog.dll` and `Serilog.Enrichers.ExcelDna.dll` in the `.dna` file of the add-in: |
| 42 | + |
| 43 | +```xml |
| 44 | +<DnaLibrary Name="My Add-In" RuntimeVersion="v4.0"> |
| 45 | + <ExternalLibrary Path="MyAddIn.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" /> |
| 46 | + |
| 47 | + <Reference Path="Serilog.dll" Pack="true" /> |
| 48 | + <Reference Path="Serilog.Enrichers.ExcelDna.dll" Pack="true" /> |
| 49 | +``` |
| 50 | + |
3 | 51 | ---
|
4 | 52 |
|
5 | 53 | _Copyright © 2018 Caio Proiete & Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html)._
|
0 commit comments