Click here to Skip to main content
15,902,777 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have two same applications: sharing same physical project and same application pool but they are hosted via two different ports, 80 and 81. I use log4Net to log from the Application_Start and _End handlers. I distinguish this two applications by also logging HttpRuntime.AppDomainAppVirtualPath because one of them is set up as sub application. What I have found is that occasionally, Application_End event is called more than once for one application when application pool is recycled (as i can see the virtual path). Is that normal? Is that because of Log4Net? Hope someone could give me the answer.
Posted
Comments
Sergey Alexandrovich Kryukov 17-Jan-12 15:52pm    
Not enough information.
--SA

1 solution

I don't think you observe excessive event raising directly. More likely that you observe the effect of some event handler. As you provided no information on your code, you should investigate the case by yourself.

Do the following: run it all under debugger and put a break point on the very beginning of the event handler in question. When your execution stops at this break point, look at the call stack window to see where the call comes from. Add more break points as you get more information. This way, you will learn all the ugly truth on what happens to you code pretty soon. :-)

Good luck,
—SA
 
Share this answer
 
Comments
Easygoing Soul 17-Jan-12 21:52pm    
Here is my code. I have written it under global.asax.vb. There is no complex logic in my code. I was just trying to know the relation between application pool recycling and Application_End event and found this weird behaviour. To my knowledge, this event will be called only once no matter what. Am I missing some basic logic? What is more, I had no problem when I tested it in VS. This is happening when the project is deployed to IIS 7. Thank you for your interest.

Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application ends

'MyTesting
Dim MyLogger As log4net.ILog = log4net.LogManager.GetLogger("EventsLogger")
MyLogger .Info("[" & HttpRuntime.AppDomainAppVirtualPath & "] " & " [Application Ended.]")
End Sub

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900