Trogdor
Trogdor

Reputation: 41

Logging custom ETW events on IIS in production

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!

Upvotes: 0

Views: 3222

Answers (1)

Chandini
Chandini

Reputation: 550

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

Upvotes: 0

Related Questions