Re: Logging Best Practice?



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
.



Relevant Pages

  • RE: [fw-wiz] Log checking?
    ... tend to evaluate where and what logging is important in a different light. ... I've been happy to analyze a year's worth of firewall denied logs, ... have denied firewall traffic logs or denied logs with any relevant data. ...
    (Firewall-Wizards)
  • Re: Login Errors Seem to indicate we are being hacked?
    ... thing on the box using that authentication package. ... The SMTP or IIS logs should answer everything. ... I'm not familiar with that particular router or its logging capabilities, ...
    (microsoft.public.windows.server.sbs)
  • [TOOL] The Logging Project
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... of a need for secure, centralized, fault tolerant, real time logging. ... system logs are only part of the package. ... * Message queuing when tunnel is offline (sptc) ...
    (Securiteam)
  • Re: Need help finding tools to diagnose SBS/Exchange prob...
    ... Its logging is fairly limited, ... Then there's the SMTP logs. ... messages explaining why the receiving servers would not accept mail. ... Most advice around this says that maximum logging degrades Exchange ...
    (microsoft.public.windows.server.sbs)
  • Where in User.Identity.Name gets a value in Login control?
    ... For a logging application I need to test the value of User.Identity.Name together with User.Identity.IsAuthenticated to direct the program flow. ... I tried Login.Authenticated, LoggedIn and Page_Load events. ... Based on whether this value equal to "admin" I would like to make a CreateUserWizard control visible if the user is authenticated. ...
    (microsoft.public.dotnet.framework.aspnet)