none
Posting to Windows Log RRS feed

  • Question

  • So all the website have you explictly creating a source, all of which do not work because I have permission errors. Now for my need I have no intrest in solving that permission error and here is why.

    Last night I found a post that was three lines of code that allowed me to write to the windows log with my name as a source. it was the ONLY (simple) code on the internet I was able to find that worked for me. Problem is, I have lost that code and the website. Anyone know how to be clever in posting temporary errors to the windows log without having to address the security of source property and without writing miles of code.

    we have a logging system already in place its just not working but I need to see the errors that are happening now so this would be stricktly temp.

    Wednesday, February 6, 2013 7:29 PM

All replies

  • I assume since you mention "website" that this is an ASP.Net Web application?  You also didn't mention the language used and that could be important because the VisualBasic namespace may include handy helpers that wouldn't normally be available in C#.

    It's always best to post ASP.Net questions to http://forums.asp.net

    So, that said, In VB it could be as simple as:

    Public Class _Default
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Try
    
            Catch ex As Exception
                My.Application.Log.WriteException(ex)
            End Try
        End Sub
    
    End Class


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


    Wednesday, February 6, 2013 8:09 PM
    Moderator
  • Oh, I also meant to add that if it is only temporary, you could just write the exception to a text file yourself and skip the event log altogether.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, February 6, 2013 8:12 PM
    Moderator
  • I will try out the solution you posted. I should have said windows service rather than website.

    As far as language goes, as far as I am concerned c# and vb.net are the same. For me its understanding the objects and methods more than syntax

    Wednesday, February 6, 2013 11:28 PM