Hi Cab, As far as my experience, use Logger using log4j and use static declaration. There should not be any problems for your application.
I think you are not writing a library application, that will be shared by other applications running on your server. So go ahead with the efficient way! Thanks and Regards, Thomas Joseph Kott Software Pvt. Ltd. | Vallamattom Estate | M.G.Road | Cochin | Kerala - 682015 | India www.kottsoftware.com _____ This email (including any attachments) is subject to copyright, the information in it is confidential, and it is legally privileged. Use of this email or of any information in it other than by the addressee is unauthorized and unlawful. If you are not the intended recipient of the mail, kindly notify the author of the mail and delete the same. -----Original Message----- From: Mon Cab [mailto:[EMAIL PROTECTED] Sent: Friday, November 17, 2006 2:19 AM To: Struts User Group Subject: Logging in Struts Good day I am having a hard time understanding how to use logging in Struts. The struts.apache.org suggest the following usage (presumably for business objects) (taken from: However, I am wondering whether this is OK, given that my business objects will be being accessed from different servlet threads. Can anyone tell me whether this is OK?, and if not, what is the correct way to do this? My second question is whether the same usage is valid for Action classes. I saw the following example, at http://www.mobilefish.com/developer/struts/struts_quickguide_log4j.html but am not certain as to whether using a static variable would be OK here. Would it? public class DemoAction extends Action { private static Log log = LogFactory.getLog("com.mobilefish.DemoAction"); public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("This is my debug message."); log.info("This is my info message."); log.warn("This is my warn message."); log.error("This is my error message."); log.fatal("This is my fatal message."); } } The commons logging documentation notes the following: Note that for application code, declaring the log member as "static" is more efficient as one Log object is created per class, and is recommended. However this is not safe to do for a class which may be deployed via a "shared" classloader in a servlet or j2ee container or similar environment. If the class may end up invoked with different thread-context-classloader values set then the member must not be declared static. The use of "static" should therefore be avoided in code within any "library" type project. I'm not clear as to what the above means, from a practical perspective in the context of a web applicaiton. What does this mean in simple terms? Taken from: http://jakarta.apache.org/commons/logging/guide.html#Configuring_Log4J ____________________________________________________________________________ ________ The all-new Yahoo! Mail beta Fire up a more powerful email and get things done faster. http://new.mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]