How can we log the message to log file using log4j api?

Showing Answers 1 - 1 of 1 Answers

Bhavani Shekhar

  • Mar 25th, 2006

LOG4J is a framework. you need to follow the standard folder structure so that you J2EE Component could write the log messages to the specified locations. To work with log4j you need to following steps:1. log4j.jar should be in the classpath. (for Web applications you can place the properties in WEB-INF)2. must be defined for the application as per the need.3. In the application component we need to defined the Logger on the Root(directory)/current class.4. you can use all the possible messaging methods for tracing the application. INFO, DEBUG, ERROR,WARN, FATAL are the various levels for log message.Remember that these messges you can directly send to console or to a file or to a JMS Queue or to a Database or thru SMTP to a mailer server etc.Most of the Organizations use to trace the performance of an application at runtime.This log message writing is much faster than System.out.println() on the Enterprise applications.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions