Re: Logging Best Practice?
- From: usenet@xxxxxxx
- Date: 29 Dec 2005 19:38:22 GMT
Jeffery <je44ery@xxxxxxxxx> wrote:
> And so on. The big difference being that some programmers say "I'm
> *about* to perform this action," and I have been saying "I just
> finished *doing* this action."
>
> The only drawback I have found to my style so far is that if something
> goes terribly (unrecoverably) wrong with step Z, then the last thing in
> the log mentions *nothing* about step Z. It only mentions something
> about step Y, which is OK for me because I know about my logging style,
> but it can be confusing for others.
My two cents: it's mostly about style, and it seems that you are already
well-informed about the pros and cons of both approaches. But of course it's
always enlightening to hear other peoples visions about such issues.
For me, a lot depends on who's going to read the logs. Low-level debugging
logs, ment for co-developers or others maintaining the code, can probably be
implemented anyway you like. Somebody with access to the source can always
lookup where the log line originated and look at the program flow.
I usually implement logging in a way the user can choose the logging level
from 'debugging', 'informational', 'warnings', 'errors' to 'fatal' (the
unix-syslog way). It's completely up to me to decide what kind of messages
fit in which category.
Debugging and informational messages (which are probably not enabled under
normal circumstances) usually tell what's about to happen (going to open the
file, going to update the record, etc). Those are ment for checking if the
program flow goes as I expected, and to see if certain actions are performed
at the moment they should.
Warnings and errors are not supposed to happen in the normal program flow,
and - due to their nature - mostly tell what just happened, and what just
went wrong.
> In some cases that have caused me particular trouble, I have added
> pre-event logging. "This program is about to perform this action!" But
> perhaps I should do this all the time?
This is probably not something you can afford under all circumstances,
unless some kind of circular buffers are used. For long-running applications
or programs that spew out a lot of logging, this will quickly eat up a lot
of memory or disk space.
You should also watch out not to flood your logs with trivial messages so
you cant see the wood for the trees anymore. A well-behaving program should
be as quiet as possible if everything is ok. No news is good news.
I think every application has it's own needs. I'm doing a lot of development
on small embedded systems which hardly have any non-volatile storage (and
*if* they have, it's often not ment to write to too often because of wearing
out). This requires a completely different way of logging then something
like a webserver with 100+ GB disk space.
_Ico
--
:wq
^X^Cy^K^X^C^C^C^C
.
- References:
- Logging Best Practice?
- From: Jeffery
- Logging Best Practice?
- Prev by Date: Re: Logging Best Practice?
- Next by Date: Re: Logging Best Practice?
- Previous by thread: Re: Logging Best Practice?
- Next by thread: Re: Logging Best Practice?
- Index(es):
Relevant Pages
|