SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: What to Log??

  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,922
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    What to Log??

    What things are a *must have* when it comes to "Logging"???

    Right now, I have a single "Error Log" table which logs the following when there is an error...
    Code:
    	- Error Type
    	- Error Code
    	- Source Page
    	- Member ID
    	- User IP
    	- User Hostname
    	- Created On
    This seems to work just fine, but now I am wondering if there other things I should be logging, such as...

    1.) When Members Log-In
    2.) When Members Log-Out
    3.) When People Register
    4.) What Pages People Visit

    And so on...


    I guess I am particularly interested in if I should be doing #1 and #2. (Technically I already log #3 in my Errors Log...)


    In the end, as website owner, what kinds of things do I need to log to help me manage my website, and to have an audit trail should issues arise?!

    Sincerely,


    Debbie

  2. #2
    SitePoint Addict bronze trophy
    Join Date
    Sep 2005
    Posts
    323
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Well a lot of what you are logging can already be found in your apache access logs. You might want to log the page referrer if you're interested to see where the user came from to get to that page.

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Log the things that will help you debug. If your log is not for debug (arguably then that should be another log) then what is it for? Stats?

  4. #4
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,922
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    Log the things that will help you debug. If your log is not for debug (arguably then that should be another log) then what is it for? Stats?
    Don't you think it would be useful to know when Members log in and log out?

    Or what pages they visit?

    Or other things that Members do?

    Think "forensics"!!


    Debbie

  5. #5
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,615
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    If you're talking forensically just to have a record of what's happening, I've been keeping track of logins/logouts, when records are deleted, when new ones are added, and when they are edited (and by whom).

    For example, I might use a blurb like this: user ID 5 (Force) deleted user ID 12 (testuser)
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  6. #6
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,922
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Force Flow View Post
    If you're talking forensically just to have a record of what's happening, I've been keeping track of logins/logouts, when records are deleted, when new ones are added, and when they are edited (and by whom).

    For example, I might use a blurb like this: user ID 5 (Force) deleted user ID 12 (testuser)
    So you support the idea of logging...


    Debbie

  7. #7
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Using the word "forensics" suggests you will be going back looking for evidence of crime.

    Define why you are logging things and then you will have a better idea of what to log.

    The danger of logging everything just because you can is that you end up with log files so huge that they obfuscate important data because of their very size.

    You can log to numerous different files, so make sure you name these files very carefully otherwise you will forget what each one is for.

    Consider using a proper logging library (PEAR::Log, ZF logging) because then you end up with just single lines of code that you have granular control over at runtime - allowing you to switch logging on and off up set the level of log up or down.

    There is another source of logging you should remember is available and that is your database log. There are plenty of options there. General log might be of interest, but could slow you db server.

    I just came off a project using SOAP to connect 5 different servers and logging was the only way to figure out what was happening.hence the importance of granular control, ease of access, naming conventions and relevance of data are fresh in my mind.

    Don't forget you can also log to a db, sqlite is ideal for this kind of thing (I created an Sqlite driver for PEAR::Log if anyone wants it, shout out).

    Once your logging is set up and if you are logging to files, then an hour spent reading about logrotate would be good.

  8. #8
    SitePoint Addict bronze trophy
    Join Date
    Sep 2005
    Posts
    323
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Not to mention logging can also slow down your site; it's one extra query for every action that you log.

  9. #9
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,615
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    So you support the idea of logging...
    It depends.

    For the system I described, it handles personal information, so it's a good way to audit who has access to the information.

    For just a general website or blog, it's probably not necessary.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •