|
---|
Replies are listed 'Best First'. | |
---|---|
Re: When to use logging and why?
by pg (Canon) on Nov 13, 2003 at 08:54 UTC | |
You don't need logging, if this world is perfect, and you don't bother to remember anything. However that's not the case. Here are things I usually log for my applications: An application without proper loggings is just like a black box. You don't know what is going on. You don't know whether something is actually happening. When something went wrong, you don't know what was wrong... So it is really for your own benefit, to create proper logging and the right amount of logging. | [reply] |
Re: When to use logging and why?
by liz (Monsignor) on Nov 13, 2003 at 08:36 UTC | |
But to answer your question, I use logging for: | [reply] [d/l] |
Re: When to use logging and why?
by DrHyde (Prior) on Nov 13, 2003 at 10:01 UTC | |
First wearing my User Hat, logging is a Good Thing because when the application goes wrong - and *all* software goes wrong at some point - it means that when I whine at the developer I can accompany my whine with information he will find useful for hunting down and fixing the bug. And wearing my Developer Hat, given that my users are going to whine at me - and *all* users whine at some point - I want them to be able to whine intelligently. Not to mention that logging is very handy indeed for debugging the rubbish I write before I release it on an unsuspecting world. Given those reasons *why* to use it, answering the *when* becomes easy - you should log *always*. Make your application log by default, allowing the user to turn logging off if they really care. The question you don't ask is *what* to log. I like to log all significant events, with a timestamp, and with some indicator of how important the event is - is it an informational notice? a warning? a failure? debugging info? Release your app with debugging turned off, but all other log levels turned on, and as well as allowing the user to turn all logging on or off, it's nice to let them turn the log level up and down. An example of a notice would be "constructor method called with parameters FOO BAR BAZ". A warning might be "constructor called with invalid value FOO for parameter BAR". A failure might be "failed to serialise object to disk". Debugging info would be hideously verbose, like for each subroutine, logging entry parameters and return values. Log files should be formatted both to be easily searchable (find all warnings in the Foo module) and easy to read. Whitespace and indentation is Good. | [reply] |
Re: When to use logging and why?
by AcidHawk (Vicar) on Nov 13, 2003 at 09:38 UTC | |
As liz and pg have already said reporting and debugging. But I also often need to run my scripts as daemons/services and can't see any output so need to see what is going on (Debugging). Also though, I need to run external programs with command line args which I have got from somewhere else (wrapper type things) I often do something as follows; type stuff, This lets me copy the exact command out of the log file (with the parameters I added) and run it from the command line to check if I have gotten any funny (un-expected) results. You will not believe how many times I have used this.. ----- Of all the things I've lost in my life, its my mind I miss the most. | [reply] [d/l] |
Re: When to use logging and why?
by jdtoronto (Prior) on Nov 13, 2003 at 14:30 UTC | |
From a corporate point of view logging can be very helpful. A few scenarios: | [reply] |
Re: When to use logging and why?
by inman (Curate) on Nov 13, 2003 at 13:16 UTC | |
Logging user activity and then analysing the data allows you to discover trends and behaviours that may not have been obvious. You only need to look at the Google Zeitgeist to see what real world information can be derived from analysing the stuff that people are searching for. I also find that log data is invaluable when trying to post-mortem an application that is running on a live system but crashes after a period of time. This type of problem is difficult to diagnose in a development environment where it always worked and the failure could not be triggered. In the live environment, the log files can be collected and analysed off-line. | [reply] |
Re: When to use logging and why?
by DaWolf (Curate) on Nov 13, 2003 at 13:50 UTC | |
Logging is a very important part of any system. I'm probably being repetitive, but I usually use it for:
my
($author_nickname, $author_email) = ("DaWolf","erabbott\@terra.com.br")
if ($author_name eq "Er
Galvão Abbott");
| [reply] |
Re: When to use logging and why?
by nimdokk (Vicar) on Nov 13, 2003 at 11:27 UTC | |
For what we do at least, I log everything that is going on, and make an attempt to capture output from external programs that the script(s) might be using for troubleshooting mainly when something goes wrong, which it invariably does. By accoutinging for this, we can capture problems, isolate them better and not crash our system when something goes wrong since all our scripts either run under cron (on Unix) or as un-attended batch jobs on Windows 2000. Normally, we only look at the logs when something has blown up, or in the initial testing stages. But we log everything religiously. It also gives us a quick idea as to how many times a script has been run (because we archive the logs for a few months). We know how often the program is successful as well as how often it fails. Logging is perhaps a matter of personal choice and also more importantly circumstance and situation. As one wise sysadmin where I work put it: "Logs are your friend." :-)
"Ex libris un peut de tout" | [reply] |
Re: When to use logging and why?
by Theo (Priest) on Nov 13, 2003 at 16:17 UTC | |
Trying to cram all of that into one log file would make it harder to find needed info, but since they serve very different functions, they need to be saved for very different periods of time. Just in case some of the log files are used in a trial, you may not want some of that other stuff made public. (that's the paranoid part of my personality) -theo- | [reply] |
by jdtoronto (Prior) on Nov 13, 2003 at 19:39 UTC | |
jdtoronto | [reply] |
Re: When to use logging and why?
by ehdonhon (Curate) on Nov 14, 2003 at 11:55 UTC | |
One of the greatest reasons to use logging is so that whenever your customers start telling you that your application isn't working right, you can determine what happened and tell them "Yes it is, you just were not using it right." Logging is great any time you as a programmer want to know what the program is doing when somebody else is using it. Because if you rely on the somebody else, the message is sure to be lost in the translation. | [reply] |
Re: When to use logging and why?
by chanio (Priest) on May 02, 2004 at 01:04 UTC | |
.{\('v')/}
_`(___)' __________________________ | [reply] |