Commons Logging priority best practices

前端 未结 6 960
一个人的身影
一个人的身影 2021-02-05 15:59

This may be a purely subjective question (if no organization has attempted to standardize this), but my team struggles with this more than you would think.

We use Apache

6条回答
  •  暖寄归人
    2021-02-05 16:26

    Here's what we use (and I'd say many others as well):

    • FATAL: errors that endanger the consistency of the system and might require an immediate shutdown/restart - very rarely manually used
    • ERROR: exceptions that should not be thrown and represent a bug in the system (normally all exceptions that are not caught up to a certain point)
    • WARN: exceptions that might occur but are accounted for or situations that might imply a logic/usage error - we decide whether to track those or not
    • INFO: whatever you need to have in the log, e.g. what users currently do (in our case of web applications: what page the user is navigating to etc.)
    • DEBUG: debug only messages like timings etc, generally turned off in the logs
    • TRACE: we don't use that, you might use it for even more specific debugging info

    In some cases we start with logging messages as ERROR, in order to get the notification when something we'd normally not like to happen occurs. Later, if we decide that the source for that error can not be removed, we handle it and change the log level to WARN.

    Note that our test and production systems are set up to send an email for FATAL and ERROR. Thus we don't have to check the log files for those manually but only have to check one email inbox.

    Hope that helps.

    Edit: did you already have a look at the Apache Commons Logging best pratices?

提交回复
热议问题