0
votes

We are planning to implement all our logging (trace, audit, activity, error etc.) using custom ETW EventSources in our ASP.NET Web API application. We would like to output these events into a logfile while being able to configure the log level.

My questions:

1. How to set up the site in IIS so that it outputs custom ETW events to a log file?

There is an option in IIS under Logging / Log Event Destination to write ETW events to a file, but it doesn't seem to produce an output at the path in the Log File / Directory field. Also, I didn't find any indication if this should work with our custom EventSource-based types or just the standard IIS ETW providers.

https://www.iis.net/learn/get-started/whats-new-in-iis-85/logging-to-etw-in-iis-85

2. How to configure this setup for production?

On one hand I tried looking up .config settings that would make this work, but I just got more confused. Do I need a custom trace listener that writes to file and reference that in web.config? Is there a build-in component which takes a file destination maybe a log level value and outputs the results?

https://www.iis.net/configreference/system.webserver/httptracing

On the other hand I found some samples for consuming these events using PerfView, but I imagine firing up PerfView on the production server for all our logs and not just debugging is not the best practice for production (or is it?):

https://blogs.msdn.microsoft.com/vancem/2012/08/14/etw-in-c-controlling-which-events-get-logged-in-an-system-diagnostics-tracing-eventsource/

Thanks!

1
@PeterBons The Semantic Logging Application Block looked perfect, until I found that it is hasn't been updated in a while and doesn't support .NET 4.6 yet :( See: github.com/mspnp/semantic-logging/issues/…Trogdor
It does run under .Net 4.6 (Am using it myself) but can't use some of the advanced stuff introduced in that version. But true, since it is stable it is not under active development. According to github.com/mspnp/semantic-logging/issues/91 github.com/Azure/diagnostics-eventflow would be recommended and seems to be more fitted for cloud scenario's. But I find it is still lacking some basic documentation.Peter Bons
@PeterBons While it does run on .NET 4.6, I'm uncomfortable in using a component in production which is specifically said not to be stabilized and tested by the production manager, and also has issues like this: github.com/mspnp/semantic-logging/issues/64 But I may just go this way if the alternative is re-implementing SLAB's file logging. I'll look into diagnostics-eventflow. Thank you!Trogdor

1 Answers

0
votes

The IIS produces an output at the path in the Log File / Directory field. You can go to C:\inetpub\logs\LogFiles\W3SVC1 and see your IIS logs.

Log file in my system

And regarding logging of custom events to log files, try to use semantic logging application block. https://msdn.microsoft.com/en-us/library/dn440729(v=pandp.60).aspx