Thursday, September 25, 2008

ASP.NET How to configure Network Tracing with TextWriterTraceListener

Setting up network tracing in ASP.NET is really simple, and takes less than 30 seconds to set up. Here is the article on MSDN:http://msdn.microsoft.com/en-us/library/ty48b824.aspx

Unfortunately for me, after completing the steps, I was not able to locate the log file (for me network.log) anywhere on the web server. I searched the directories where a log file might appear: Windows, System32, LogFiles and the root directory of the site with no luck.

After reading around the Internet, I found the solution: Grant the NETWORK user Write access to your site.

Here is a simple set of steps to set up network tracking, and have it work properly:
1. Follow the steps listed in this article on MSDN: http://msdn.microsoft.com/en-us/library/ty48b824.aspx
2. Grant the NETWORK user Write access to your site.

After completing these steps, the trace log appeared in the root directory of the site.

Here is a sample of the output from the trace log:

System.Net Verbose: 0 : [3800] WebRequest::Create(http://omitted.zip)
System.Net Verbose: 0 : [3800] HttpWebRequest#15225125::HttpWebRequest(http://omitted.zip#-1695293777)
System.Net Verbose: 0 : [3800] Exiting HttpWebRequest#15225125::HttpWebRequest()
System.Net Verbose: 0 : [3800] Exiting WebRequest::Create() -> HttpWebRequest#15225125
System.Net Verbose: 0 : [3800] HttpWebRequest#15225125::GetResponse()
System.Net Information: 0 : [3800] Associating HttpWebRequest#15225125 with ServicePoint#26458746
System.Net Information: 0 : [3800] Associating Connection#39449526 with HttpWebRequest#15225125
System.Net.Sockets Verbose: 0 : [3800] Socket#50346327::Socket(InterNetwork#2)
System.Net.Sockets Verbose: 0 : [3800] Exiting Socket#50346327::Socket()
System.Net.Sockets Verbose: 0 : [3800] Socket#50346327::Connect(201:80#-910221552)
System.Net.Sockets Error: 0 : [3800] Exception in the Socket#50346327::Connect - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
System.Net.Sockets Verbose: 0 : [3800] Socket#50346327::Dispose()
System.Net Error: 0 : [3800] Exception in the HttpWebRequest#15225125:: - Unable to connect to the remote server
System.Net Error: 0 : [3800] at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.Connection.CompleteStartConnection(Boolean async, HttpWebRequest httpWebRequest)
System.Net Error: 0 : [3800] Exception in the HttpWebRequest#15225125::EndGetResponse - Unable to connect to the remote server
System.Net Error: 0 : [3800] at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.Connection.CompleteStartConnection(Boolean async, HttpWebRequest httpWebRequest)


Resource articles:
How to: Configure Network Tracing
How To: Use the Network Service Account to Access Resources in ASP.NET

No comments: