Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for structured logging for diagnostics #277

Open
augustoproiete opened this issue Nov 10, 2019 · 3 comments
Open

Add support for structured logging for diagnostics #277

augustoproiete opened this issue Nov 10, 2019 · 3 comments

Comments

@augustoproiete
Copy link
Member

Excel-DNA's Diagnostic Logging feature allows the developer to configure a TraceListener that will be used by Excel-DNA to write diagnostic log messages, which can then be forwarded to any logging pipeline such as Serilog or NLog, for example, in order to consume / analyse these logs outside of the user's machine.

Unfortunately, the standard Trace feature that comes with .NET only does simple text logging and does not provide structured logging capabilities, and important information is lost by the time messages reach the logging pipeline.

image

It would be great if Excel-DNA moved away from Trace and added support for structured logging within its diagnostic logging, and provided an extension point for the developer to attach structured logging providers at run-time.

Ideally it should use Microsoft.Extensions.Logging which is the current standard for modern .NET apps.

@n1l
Copy link
Contributor

n1l commented Jan 14, 2020

What do you think about ETW?

@augustoproiete
Copy link
Member Author

augustoproiete commented Jan 14, 2020

@n1l Are you suggesting we write logs directly to ETW from within Excel-DNA?

It's definitely possible, but I see ETW more as a possible "destination" for the logs, instead of a "source" for logs.

I think Excel-DNA should not decide where to write logs, and instead provide a mechanism that allows the user to plug-in any .NET logging library that he/she wants, such as Serilog or NLog, for example, and the logging library then decides where the logs are written based on configuration provided by the Excel Add-In.

That way, if the user wants logs to end up in ETW, they can do so via the integration provided by the logging library they are using.

e.g.
image

Does that make sense?

The Trace mechanism used in Excel-DNA today already provides a way to get the pipeline above by implementing a custom TraceListener (see ExcelDna.Diagnostics.Serilog for example) that forwards logs to a logging library, but everything is written in plain text without preserving field names and values.

I think Microsoft.Extensions.Logging at the moment would be the best candidate for the logging API glue, replacing the Trace.

@n1l
Copy link
Contributor

n1l commented Jan 16, 2020

Yes It's absolutely does, and I definitely need to try it out, thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants