We are trying to debug some web services code we're running in C# on IIS. I am new to Windows programming and have no idea how to view output to the console. We've got some write statements in the code, but I can't figure out how to view the console while this thing is running. Help?
-
If you're using asp.net then trace.axd should contain trace statements (as long as its turned on).
-
You aren't going to get a console for IIS. CLOSEST you will come is Debug.WriteLine w/ a debugger attached or using page tracing. Recommendation would be to use a logging framework that will write to debugger (when attached) as well as a file and possibly the event log (all configured via your listeners).
Some great ones are log4net and NLog.
Arnshea : Since .net comes with built in logging I always wonder why people still use other logging packages...Darren Kopp : because tracing doesn't work when in a production environment. and w/ shared components, you don't want to be tied to web based logging if the same code will be used on the web as well as a windows app or service.Arnshea : The Trace in System.Diagnostics doesn't work in production? I'm pretty sure they do, as long as it's enabled. Built in trace switches, trace sources, filters and listeners...Darren Kopp : if you haveset in the config (which you should for production), then it disables it. -
You'll want to take a look at ASP.NET tracing
here is a handy link to get you started: http://www.asp101.com/articles/robert/tracing/default.asp
you can enable application wide tracing if you place the following in your web.config, then you will have access to your trace.axd
<trace enabled="true" localOnly="false" pageOutput="false" requestLimit="500" traceMode="SortByTime" />MaxGeek : I found it useful.RSolberg : Wow - get the answer even after stealing the answer from someone else! -
I have found the Trace feature extremely helpful. You can get there by going to: http://mysiteurl/trace.axd
In your web.config, place the following within the System.Web tag:
<trace enabled="true" localOnly="false" pageOutput="false" requestLimit="500" traceMode="SortByTime" />Now from your code behind, you can inject some logging by doing:
HttpContext.Current.Trace.Warn("I Made It Here!");
0 comments:
Post a Comment