logging application for a web application developed in ASP.net 3.5

Hello
I am developing a web application Social networking site using ASp.net 3.5 and VS 2008
I am looking for a logging application tool and have come across two of them

1.> http://logging.apache.org/log4net/
2.> http://www.davidhayden.com/blog/dave/archive/2006/02/19/2806.aspx

if you have any better, please let me know.

I am looking for a tool which isnt
a.> heavy and doesnt make the application run slowly
b.> i should be able to compile with the log messages disabled i.e in visual studio I should have the option  to compile with the logging application disabled

thanks
jbajajAsked:
Who is Participating?
 
samtran0331Connect With a Mentor Commented:
I haven't used log4net before, but looking at the site; I would guess that it would be highly recommended to compile it with the application because it is integrated with the applicaiton itself.
I have used the MS-App blocks before and I know this to be the case.

I doubt either would slow down the performance of your application.
It would only increase the build time in Visual Studio (which would be minor) and increasee the size of your final compiled dll(s) for the app.  But it wouldn't mean a performance decrease.

Even if you choose to include one of the tools you listed; I would still recommend you put a key in web.config to enable/disable whether the logging is active or not.
0
 
samtran0331Commented:
Both are probably "heavier" than you need.
Both are basically wrappers for things you can do yourself, so in my opinion, both are going to add overhead.  
Using these tools will give you a robust logging system, but if you don't need all the features and  if your goal is to be as lightweight as possible, I would suggest you use neither.

If you look in the second example, the core of what you need to capture an error is:


    void Application_Error(object sender, EventArgs e)
    {
        Exception ex = Server.GetLastError().GetBaseException();
       
        string message = ex.Message +
                        "\nSOURCE: " + ex.Source +
                        "\nFORM: " + Request.Form.ToString() +
                        "\nQUERYSTRING: " +                            Request.QueryString.ToString() +
                        "\nTARGETSITE: " + ex.TargetSite +
                        "\nSTACKTRACE: " + ex.StackTrace;
        Logger.Write(message);
    }


The only thing that including the enterprise library does is give you the:
        Logger.Write(message);


And you can create a simple function to do something with the message yourself (insert it into a db, email it to a support email address, etc.)

as to the second part of being able to enable/disable it.
I would simply put a key in the web.config that would be either "true/false" which would either log your errors or not.
0
 
jbajajAuthor Commented:
Thanks so much Samtran

However could there be a way I could add this tool, but not compile it
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.