struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mathew, Manoj" <>
Subject RE: log4j setup
Date Wed, 24 Sep 2003 14:11:42 GMT

there are three ways( known to me) to load the log4j at the server startup
 1.Create ur own servlet put the code in Init()and load it at the begining of your application
 2.Extend Action Servlet
 3.  through the following way.

I find the 3rd one better because it sound like struts way of doing it...!!
  this is what we have done..

in struts config
<!-- ========== Plug Ins Configuration ================================== -->
	<plug-in className="" />


public class ApplicationStartup implements PlugIn {

	public void init(ActionServlet servlet, ModuleConfig config) throws ServletException {
		try {
			Category cat = Category.getInstance(ApplicationStartup.class);"log4j has been properly configured on application startup.");
		} catch()

this will load and configure your log$j each time you start your server..

then i have a class which handle the logging..

public final class MylLogger {
	public static String LOG4J_PROPERTIES_FILENAME_TEST = "";
		public static void configureLog4J() {
		try { is = ProposalLogger.class.getResourceAsStream(filename);
			java.util.Properties prop = new java.util.Properties();
		} catch {}
		Category cat = Category.getInstance(ProposalLogger.class.getName());" Log4J logging has been properly configured using file " + filename + ".");
then I use these two these two methods do my logging..
public static void logError(Category category, String msg, CustomerLoggingInfo customerInfo)
public static void logTiming(Class caller, long start, long end, String msg) {}

If anybody has any better idea please let us know.

-----Original Message-----
From: Davide Bruzzone []
Sent: Wednesday, September 24, 2003 8:41 AM
To: Struts Users Mailing List
Subject: RE: log4j setup

Here are the steps:

- Make sure that the appropriate Log4J JAR file is in your /WEB-INF/lib
- Put your file in /WEB-INF/classes
- Wherever you want to log, add the following code:

import org.apache.log4j.Logger;


// This is a private static attribute within the class
private static Logger logger = Logger.getLogger(<The name of the


// When you want to log something...

Hope this helps... If you need more information about the file, etc., the Log4J site points to lots of great (and
very detailed) documentation that you can use as a starting point...


Dave Bruzzone

-----Original Message-----
From: Viral_Thakkar [] 
Sent: Wednesday, September 24, 2003 7:23 AM
To: Struts Users Mailing List
Subject: log4j setup

Please let me know what are the steps one need to do to configure the

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message