App Service Custom IIS logging in .Net Framework 4.8 sample?

Graham Freckleton 0 Reputation points
2026-08-31T19:56:09.0633333+00:00

We are looking for custom IIS logging samples for our app service running .Net Framework 4.8 in Windows. Particularly, some mapping details for the standard W3C logging format used by the built in IIS logger. Some fields are bit difficult to find (for example sc-bytes, cs-bytes and time-taken). Any caveats with custom logging would be appreciated as well.

Background: We have moved our application to Managed Identity (MI) but discovered that the App Service -> App Service logs -> ``Web server logging (built-in) logging does not support MI, only storage access keys.

Sidenote: We are using NLog for the logging framework.

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.


2 answers

Sort by: Oldest
  1. Andriy Bilous 12,191 Reputation points MVP
    2026-08-31T20:11:25.16+00:00

    Hello Graham Freckleton

    There are two ways to get real IIS logs without storage keys

    Before writing a custom logger, note that the three fields you call out (sc-bytes, cs-bytes, time-taken) are measured in HTTP.sys, below the managed pipeline an in-process logger can only approximate them. Two platform options give you the true values with no access keys:

    1. Diagnostic settings → Log Analytics (recommended). App Service Diagnostic settings (Azure Monitor, not "App Service logs") has an HTTP logs category that lands in the AppServiceHTTPLogs table. It contains the genuine IIS values: ScBytes, CsBytes, TimeTaken, ScStatus, ScSubStatus, ScWin32Status, CsUriStem, CsUriQuery, CsUsername, UserAgent, Referer, Cookie, CIp, SPort, ComputerName. Sending to Log Analytics or Event Hubs involves no storage keys at all. (Caveat: the storage account destination of diagnostic settings still writes with account keys internally, so it breaks on shared-key-disabled accounts just like the built-in blob logging see this Q&A.)
    2. Keep "Web server logging = File System" (needs no storage account; quota-limited, rotating) and ship D:\home\LogFiles\http\RawLogs\*.log to blob yourself with a scheduled WebJob using Azure.Storage.Blobs + DefaultAzureCredential. True IIS logs, MI-authenticated shipping, no custom request instrumentation.

    There is no official Microsoft sample that reproduces the complete W3C line (with sc-bytes/cs-bytes/time-taken) from inside a Framework app because those three values are produced by HTTP.sys below the managed pipeline.

    W3CLogger in ASP.NET Core a modern ASP.NET Core has this exact feature built in (W3C-format request logging middleware), plus metaljase/HttpLoggingW3CLoggingSerilogExamples with runnable examples.

    Was this answer helpful?


  2. Jose Benjamin Solis Nolasco 12,036 Reputation points Volunteer Moderator
    2026-08-31T20:12:32.02+00:00

    @Graham Freckleton I hope you are doing well,

    For Windows App Service, the built-in web server logs are W3C extended logs generated by IIS. App Service stores these under /LogFiles/http/RawLogs/.

    For the fields you're looking for:

    • cs-bytes – bytes received from the client
    • sc-bytes – bytes sent to the client
    • time-taken – request processing time in milliseconds

    IIS documents TimeTaken as the time from receiving the request through the final IIS send completion.

    One important caveat is that App Service doesn't expose every IIS field; for example, s-computername, s-ip, and cs-version aren't supported.

    If you're moving away from Storage access keys because of Managed Identity, I would keep the IIS access-log semantics separate from NLog application logging. NLog can reproduce many of these values, but it won't necessarily have the same request-level timing and byte counts that IIS/HTTP.sys has.

     

    For reference:

    ·       Enable diagnostic logging in Azure App Service

    ·       IIS W3C logging fields

     

    If this answer helped clarify the platform capabilities and save you troubleshooting time, please consider marking it as Accepted. This helps others in the community find similar solutions. 

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.