File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes what is the use of setting levels in log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "what is the use of setting levels in log4j" Watch "what is the use of setting levels in log4j" New topic
Author

what is the use of setting levels in log4j

s. anitha
Greenhorn

Joined: Jan 18, 2005
Posts: 18
i m very new to log4j. what is the use of setting levels in log4j.
debug,warn,info.what is the difference between this.

plz help me to know this thiongs
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
"Anitha India",

Welcome to JavaRanch. We don't have many rules here, but we do have a naming policy which we try to follow very closely. Please re-read this policy and edit your display name in order to comply.

Regarding your question, this is the Struts forum and is not really an appropriate place to get this question answered. Moved to Other Open Source Projects forum where you're more likely to receive the answer you're looking for.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
what is the use of setting levels in log4j.
debug,warn,info.what is the difference between this.

The logging levels are used for filtering log messages based on importance. For example, to aid debugging people add logging statements around their code so that they can later on analyze the log to see what happened right before the system crashed or right before a user got a mysterious error message, etc.

Now, you might have thousands of these logging statements all around your code, with each user action effectively causing dozens of statements being executed. If you keep your logging level on DEBUG, all of these dozens, even hundreds of statements will be written to the log file, which takes up a lot of resources both in terms of file I/O and diskspace.

What people typically do is to set the logging level to INFO in a production environment. This effectively means that all debug-level statements are filtered out and will not be written anywhere, thus saving resources and improving the system's performance, while all messages on level INFO, WARN, ERROR and FATAL will still get written to the log file -- it's just the DEBUG stuff that we wanted to get rid of.

Now, you might consider those INFO messages to be rather useless as well and also taking up a lot of disk so you switch the logging level up another notch, to WARN, meaning that now everything below WARN will get filtered out and you'll only get WARN, ERROR and FATAL messages into your log file.

Did that answer your question?


PS. your display name is still not quite in compliance -- the policy requires a first name and a last name, or at least an initial for the first name. Could you fix that, again? Thanks.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the use of setting levels in log4j
 
Similar Threads
log4j Vs Eclipse Debugging
General debugging class??
Log4J properties in Production
log file is empty
log4j