I find it helpful to put a small comment block next to my loggers in my
config file:
<!--
General guidelines for log4net levels:
DEBUG - lots of information; exception optional
INFO - generally one line messages without exceptions to show progress
of application
WARN - usually occurs when a recoverable exception occurs; include
exception
ERROR - unexpected exceptions; include exception
FATAL - really bad; may be reservered for startup; include exception
OFF - no logging;
-->
A new production system is set to INFO for a few days then moves to
WARN or ERROR.
I don't know how I feel about people adding new logging levels to their
projects. I think the built in levels are more than adequte. What if
you happened to name your new level QUICK_TRACE. What does that mean?
When should it be used? How is that different from DEBUG? Do I need to
worry about anything if I want to upgrade log4net?
My reference for proper log usage has always been the Struts Framework
(Java MVC framework for web sites). They do an excellent job of giving
the user lots of useful information without littering the logs with
not-so-useful information. My favorite logging statements (that sounds
a bit nerdy doesn't it?) are from the iBatis (www.ibatis.com) project:
DEBUG [http8085] - Checked out connection 3976572 from
pool.
DEBUG [http8085] - {conn-100003} Connection
DEBUG [http8085] - {pstm-100004} PreparedStatement:
insert into UserAudit (UserId, AuditEvent, DateOccurred) values
(?,?,?)
DEBUG [http8085] - {pstm-100004} Parameters: [1,
audit.login.success, 2004-09-13 11:45:17.642]
DEBUG [http8085] - {pstm-100004} Types: [java.lang.Integer,
java.lang.String, java.sql.Timestamp]
DEBUG [http8085] - {pstm-100005} PreparedStatement:
SELECT LAST_INSERT_ID() AS id
DEBUG [http8085] - {pstm-100005} Parameters: []
DEBUG [http8085] - {pstm-100005} Types: []
DEBUG [http8085] - {rset-100006} ResultSet
DEBUG [http8085] - {rset-100006} Header: [id]
DEBUG [http8085] - {rset-100006} Result: [452]
DEBUG [http8085] - Returned connection 3976572 to pool.
- Ron
--- Simon Wallis <[EMAIL PROTECTED]> wrote:
> Thanks for your thoughts Erik.
>
> I would have said that FATAL is for serious errors affecting system
> functionality, and ERRORs were less serious problems that should
> still be monitored to see if they reoccur.
>
> It seems like your use of WARN is like my ERROR, and your ERROR is
> like my FATAL. How do you use FATAL events then?
>
> I added a new log level called TRACE which is lower in priority to
> DEBUG. I use for statistical info.
>
> How do you use DEBUG? Is it just for things like "entering function
> X", "exiting function X", etc? Or do most people not use that level
> of detail? If you wanted to investigate why a problem occurred,
> wouldn't you need such DEBUG statements to do a full investigation? I
> think the overhead of logging all that in production might be too
> great though.
>
> Thanks and hopefully others have some input on this too.
>
> Simon.