Logging certain type of events

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SvenV
    New Member
    • Oct 2008
    • 50

    Logging certain type of events

    Hello,

    I'm creating an application and want to build some kind of logging system.
    I want to first create my list of events in database with a certain code. Then when the operation occurrs I want to log this event in my database together with this code.

    My table with event codes would look something like this:
    CODE DESC

    and the events logging table would look like this
    ID EVENTCODE USER TIME


    Now i'm wondering how I would do this in code. How do I keep track of which codes I have because if someone deletes a user for instance I would log something like:
    1 DELUSR JOHN 5/5/2009 12:33

    How can I keep track of this dynamically?
    I don't want to create an enum and link these enums to a certain code because is too static for me.

    Any idea someone?
  • cloud255
    Recognized Expert Contributor
    • Jun 2008
    • 427

    #2
    Hi

    Somewhere you will have to tell your application which event to log. There is no way that the program can know what event corresponds to which eventcode without you explicitly specifying it.

    So in your event handlers you will have to go to the DB to get the eventcode and then write that to your logging table.

    Some of your events will most likely cause a change to your data, in this case you can use DB triggers to do the logging as this will save you one DB call to log the action.

    Comment

    Working...