code-snippets/docs/dotnet/system-net-logging.md
Liam Pietralla 8ad5845efc
Some checks failed
Build, Test & Publish / Build and Publish Container Image (push) Has been cancelled
Build, Test & Publish / Deploy to Infrastructure (push) Has been cancelled
Build, Test & Publish / Build (push) Has been cancelled
initial commit
2024-09-05 13:54:08 +10:00

874 B

Enable System.NET Logging in .NET Framework

The following code snippet shows how to enable System.NET logging in ASP.NET. System.NET logging is mostly useful for debugging issues relating to HTTP requests and responses. Often this is useful when proxies are involved, or when you need to see the raw HTTP request and response.

To enable System.NET logging, add the following to your web.config file inside the <configuration> element:

<system.diagnostics>
    <trace autoflush="true" />
    <sharedListeners>
        <add name="file" initializeData="D:\\network.log" type="System.Diagnostics.TextWriterTraceListener" />
    </sharedListeners>
    <sources>
        <source name="System.Net" switchValue="Verbose">
            <listeners>
                <add name="file" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>