ASP.NET - Applicationlog - Asked By lakshmi chaitanya on 04-Jan-12 01:56 AM

   how to create an application log in global.asax page
Suchit shah replied to lakshmi chaitanya on 04-Jan-12 01:59 AM
Please have a look on below articles.... i just recentrly read to add global exception handling and this will be also help to you also
Jitendra Faye replied to lakshmi chaitanya on 04-Jan-12 02:02 AM
You can create this using EventLog class.

follow this code-

private void btnCreateEventLog_Click(object sender, System.EventArgs e) {
 if (txtEventLog.Text.Length > 0 && txtEventSource.Text.Length > 0) { System.Diagnostics.EventLog.CreateEventSource(
txtEventSource.Text, txtEventLog.Text);
MessageBox.Show("Event Log and Source " +
"created successfully.");
} else { MessageBox.Show("Please fill in both the " +
"Event Log and the Event Source.");
Riley K replied to lakshmi chaitanya on 04-Jan-12 02:04 AM

In the application error event handle eventlog

void Application_Error(object sender, EventArgs e)
    // Obtain the URL of the request
    string url = Request.Path;
    // Obtain the Exception object describing the error
    Exception error = Server.GetLastError();
    // Build the message --> [Error occurred. XXX at url]
    StringBuilder text = new StringBuilder("Error occurred. ");
    text.Append(" at ");
    // Write to the Event Log
    EventLog log = new EventLog();
    log.Source = "Core35 Log";
     // log.WriteEntry(text.ToString(), EventLogEntryType.Error);

dipa ahuja replied to lakshmi chaitanya on 04-Jan-12 02:51 AM
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
    Dim username As String = Session("logonName")
    Dim mylog As myNameSpace.MyLogClass = New myNameSpace.MyLogClass(Server.MapPath("log"), "UserLog")
    mylog .Write("test")
    If username IsNot Nothing Then
      Dim user As MembershipUser = Membership.GetUser(username)
      user.LastActivityDate = New DateTime(1900, 1, 1)
    End If
End Sub
Sri K replied to lakshmi chaitanya on 04-Jan-12 03:42 AM
For Database side, In CP you can find many articles. Here you go[][][][][]
For application side you may use the below one[]
kalpana aparnathi replied to lakshmi chaitanya on 04-Jan-12 04:38 AM

Try this code:

public class SoapExceptionHandler : System.Web.Services.Protocols.SoapExtension
public override void ProcessMessage(System.Web.Services.Protocols.SoapMessage message)
if (message.Stage == SoapMessageStage.AfterSerialize)
if (message.Exception != null)
public override object GetInitializer(Type serviceType)
return null;
public override object GetInitializer(LogicalMethodInfo methodInfo,
 SoapExtensionAttribute attribute)
return null;
public override void Initialize(object initializer){ }
public class ExceptionHandlingAttribute : SoapExtensionAttribute
public override Type ExtensionType{get { return typeof(SoapExceptionHandler); }}
public override int Priority{get{return 0;}set{}}
You can apply this attribute to your XML Web service methods and thus enable your newly created SoapExtension.
[WebMethod] [ExceptionHandling] public void Foo(){}