Logging in ASP.NET - asp.net

Is there any logger to asp.net like the System.ServiceModel.MessageLogging used in WCF?

There is health monitoring: http://msdn.microsoft.com/en-us/library/ff650305.aspx. It has a bunch of predefined events, plus you can create your own custom events for tracking purposes.

You could use log4net for this... log4net Website

Not sure what you are actually asking for. There is ASP.NET tracing and trace.axd handler to browsing traces.

After having used it myself, I'd like to suggest ELMAH:
ELMAH (Error Logging Modules and
Handlers) is an application-wide error
logging facility that is completely
pluggable. It can be dynamically added
to a running ASP.NET web application,
or even all ASP.NET web applications
on a machine, without any need for
re-compilation or re-deployment.

Related

ASP.Net web forms with ServiceStack.Net

I have a ASP.Net web application with around 100 forms. The coding is in VB.Net. We now want to add servicestack.net services inside this application. We want to do this so that session can be shared between the asp.net application and the web service and authentication can also be done via the web application. Please let me know if this is possible, if yes can one anyone point me to a sample application or provide me with the web.config and global asax file configuration that I should use for this.
Yup, servicestack supports asp.net web forms. You can try this nuget package . I don't really sure about session as service stack using something different mechanism for session. But yes you can share the session explained here in session section.
I hope this will help. Please let me know if any further details are needed.

how to do logging in asp.net application IIS?

i have a asp.net web application written about 2 years ago .It does not have any logging mechanism in it. Ideally I would like to log any errors that happen especially at the database level. I cannot afford to break the application however, and I have limited time.
I have heard about ELMAH. Is it possible to have something that doesn't talk to my code directly and just does its own thing by monitoring the server?
It was made in ASP.NET 3.5.
It has AJAX as well as heavy use of ViewState.
The application also communicates with Excel.
It is built in Visual Studio 2008 w/ SQL Server 2005 on the backend.
How do I go about deploying this website with above requirements?
Yes.
Added ELAMH to your application - it will log the errors. It's non-invasive.
Once ELMAH is added to your application it hooks into the OnError Event and captures all errors throw by your application. This is assuming that your application does not swallow the errors.
The documentation around ELMAH is through and easy to follow.
There is also log4net -
http://logging.apache.org/log4net/

Using ELMAH in currently running website

I have a asp.net website developed in asp.net 2.0 on production which is using enterprise library for keeping the log/error and saving them into the text file. Can I use ELMAH without comipling the website and read log/error via ELMAH interface?
ELMAH can be very well used without recompile, however note that if your existing logging frameworks are handling errors, then elmah may not be able to get the error since other frameworks would have taken some actions and used up the stack trace of it.

Asp.Net 4.0 Profiling on IIS7

New to both Asp.Net 4.0 and IIS7 deployment.
I am having a runtime problem with my application. Basically certain pages are not loading, also looks like a memory issue related to certain calls etc.
What are some of the tools and techniques for profiling/debugging Asp.net 4.0 when deployed on iis7. I am just looking for a way to get the BIG picture and the drill down to smaller level.
Is it suggested that any profiling of value take place in VS2010?
You can use iis7 failed request logs to track which handler is causing pages to fail out. Using this approach, you can narrow down where the issue is happening, and then use asp.net page level tracking and exception stack traces in your event log to solve the problem. Also, good logging in your global.asax application_error method is always recommended.

Hosting a .net assembly for COM interop with long lifetime?

I have a component (an assembly built in .net) that i need to access on (almost) every request to two different websites. One website is written in classic asp and the other one in asp.net mvc.
At the moment i reference the assembly in the asp.net solution and call it like i would any .net assembly. On the classic asp website, i call it through a COM wrapper.
This is all good, except now i need this component to actually stay alive and monitor changes to a configuration file. In my asp.net website i could keep a refence in the application scope and i guess i could register it in component services for the asp access.
Is this the best way to do it? Also, this way the component would actually be hosted twice - one instance in the asp.net application scope and one in the component services. I could perhaps instead only have it live in component services, and then instead reference it from asp.net.
I don't know - something smells fishy (and no, it's not me) - am i on the right track or do you see better alternatives?
Do you really need a long running object? You say you need to monitor configuration file changes -- when the config changes do you need to trigger some actions or do you just need to ensure that each incoming request uses the latest copy of the configuration for your component? If it is the latter then standard .NET configuration should work for you without concern for the object lifetime.
In terms of hosting, do you need to use any COM+ services? If not, then I would not use COM+. If you want one central location for your .NET component, why not register it in the GAC?
Ok so i think i found two solutions, both acceptable for this project:
1) Register it in global.asa on the Application_OnStart in the Application object like this Application("Someobject") = Server.CreateObject("Someobject")
2) Host it in component services and handle lifetime there.

Resources