2 Replies - 1340 Views - Last Post: 12 February 2014 - 09:14 AM Rate Topic: -----

#1 complete  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 102
  • Joined: 12-April 07

how can I log debug info on the server?

Posted 13 January 2014 - 02:35 PM

How can I log debug info on the server?



I would like to have some way of tracing an ASP.NET application in production that is no longer in debug mode. I suppose I can try with some sort of pop-up windows, but, before I give that a try, I want to try to implement some way of the code writing out content on the server into a log file.

The code that I have inherited from a developer that is no longer with us, has an existing class that seems to be designed for this purpose:

public class DebugTextWriter : System.IO.TextWriter
    {
        public override void Write(char[] buffer, int index, int count)
        {
            HttpContext.Current.Response.Write("<textarea>" + new String(buffer, index, count) + "</textarea>");
           
        }

        public override void Write(string value)
        {
            HttpContext.Current.Response.Write("<textarea>" + value + "</textarea>");
           
        }

        public override Encoding Encoding
        {
            get { return System.Text.Encoding.Default; }
        }
    }

This does not seem to do much of anything to me. Where is the code written to?

When I look at the bit of code that implements this class, I do not see a file referenced:

Applications.DebugTextWriter dbgTextwriter = new DebugTextWriter();
            dbgTextwriter.Wriet("some message") ;


Any suggestions? Where would the output log file be if one is not specified?

Is This A Good Question/Topic? 0
  • +

Replies To: how can I log debug info on the server?

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 221
  • View blog
  • Posts: 1,478
  • Joined: 16-March 11

Re: how can I log debug info on the server?

Posted 17 January 2014 - 09:08 PM

That code just writes the debug info into a textarea and sends it into the response stream of the page. I.E. it sends it to the page to be displayed with the rest of the response from the server. A good way would be writing to a textfile with a system.io.streamwriter.
Was This Post Helpful? 0
  • +
  • -

#3 TheAKB  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 59
  • Joined: 11-November 08

Re: how can I log debug info on the server?

Posted 12 February 2014 - 09:14 AM

A good way to do this is to use Log4Net, it's just a .Dll, but is really handy.

http://logging.apache.org/log4net/

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1