standard uses of log4j's 5 levels
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   joanna_zhao
Posted On:   Monday, January 16, 2006 11:29 AM

I'm currently doing a research on the standard usage of the 5 levels of Log4j. My question is that is there a standard convention of which level to use when we program? Like should we use DEBUG more often than INFO? I understand that there are certain circumstances which require us to use a specific level. However, how about when we don't have the special cases; which level do we use usually (esp. when we write programs at the production level)? Is there a general concensus/convention/standard? Also, what is a good approach/standard for logging entry and exit of the method? I know that this might be a quite specific question. I'm also trying to find out what other programmers/companies are doing...(do t   More>>


I'm currently doing a research on the standard usage of the 5 levels of Log4j. My question is that is there a standard convention of which level to use when we program? Like should we use DEBUG more often than INFO? I understand that there are certain circumstances which require us to use a specific level. However, how about when we don't have the special cases; which level do we use usually (esp. when we write programs at the production level)? Is there a general concensus/convention/standard?




Also, what is a good approach/standard for logging entry and exit of the method?




I know that this might be a quite specific question. I'm also trying to find out what other programmers/companies are doing...(do they have a standard way of using it?) But It seems really hard to find exact information I'm looking for. If anyone could offer some outlets for finding the solutions to my question, that'd be great. Thank you.

   <<Less

Re: standard uses of log4j's 5 levels

Posted By:   jaikiran_pai  
Posted On:   Tuesday, January 17, 2006 01:30 AM

DEBUG messages --> Most of the times these messages are meant for debugging activities(mostly when the application is being developed)


INFO messages --> These messages are meant to provide some significant information about some activity in the application


WARN messages --> Messages which inform that some activity has taken place which might result in some unexpected behavior later and might need attention


ERROR messages --> As the level itself indicates, any erroneous activity can be logged using this level


FATAL messages --> Worst case where the application is going to fail


Keep in mind that irrespective of what level you have used in your code for logging, in most of the cases when your application goes into production, the priority level is set to INFO. So only those messages which you have logged with priority of INFO or higher will get logged. This in itself might help you in deciding which level to use while logging messages through your code.

Re: standard uses of log4j's 5 levels

Posted By:   Christopher_Koenigsberg  
Posted On:   Monday, January 16, 2006 02:56 PM

Just use DEBUG most of the time, unless it's something important (you can change the logging level for specific loggers named for your specific classes to enable or disable the output). If it really is a bad problem, use ERROR or WARN. But otherwise just use INFO.



Think of the sysadmins, who will eventually be reading the log file and trying to figure out whether there's a problem with your application. Think of what you can do to help them.



If you use ERROR or WARN too often, it's like "the boy who cried wolf" in the fairy tale -- the messages lose their significance.



(I've learned the hard way, like with a web application where I mistakenly was logging an ERROR every time some user's session timed out, for instance .... the sysadmins hated it ... an ERROR message should really be something that the sysadmins should HAVE to take notice of and do something about, like restarting the server or paging the support team)
About | Sitemap | Contact