RE: Tomcat 5 : DEBUG level
I think you need to setup a logger, if using java1.4 then just use built in java.util.logging.Logger, otherwise maybe log4j, prob best to create a file logger and log ALL webapp spcefic messages to it here is mine if you need something to start, its a singleton so you'd typically invoke with cdmanager.CdManagerLogger.getInstance().logp( Level.FINE, this.getClass().getName(), yourMethodName, your output message); === package cdmanager; import java.util.logging.Logger; import java.util.logging.Level; import java.util.logging.FileHandler; public class CdManagerLogger { protected static java.util.logging.Logger logger = null; private CdManagerLogger() { if(logger==null) { // Initalize the instance of the class logger = java.util.logging.Logger.getLogger(); try { FileHandler fh = new FileHandler(D:\\JBuilder9\\myprojects\\cdmanager\\logs\\cdmanager.log); fh.setFormatter(new java.util.logging.SimpleFormatter()); // Send logger output to our FileHandler. logger.addHandler(fh); logger.setLevel(java.util.logging.Level.ALL); } catch(Exception e) { e.printStackTrace(); } } } static public java.util.logging.Logger getInstance() { if(logger!=null) return logger; else { new CdManagerLogger(); return logger; } } } -Original Message- From: Francesco Pellegrini [mailto:[EMAIL PROTECTED] Sent: Thursday, April 15, 2004 9:28 AM To: Tomcat Users List Subject: R: Tomcat 5 : DEBUG level Hi, getServletContext().log(message...); When I was in Servlet class or in JSP pages I can use it, but How can I log message if I'm in Model or Controller layer ( my application is tie-tier), for examples in MyDBConnection.class and I don't have a ServletContext? Thanks, Francesco. -Messaggio originale- Da: Shapira, Yoav [mailto:[EMAIL PROTECTED] Inviato: giovedi 15 aprile 2004 15.04 A: Tomcat Users List Oggetto: RE: Tomcat 5 : DEBUG level Hi, getServletContext().log(message...); RTFM. Yoav Shapira Millennium Research Informatics -Original Message- From: Francesco Pellegrini [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 13, 2004 12:02 PM To: Tomcat Users List Subject: Tomcat 5 : DEBUG level Hi all, I'm looking for an help to customize a LOG level for my server. I have some JSP and SERVLET that uses : System.out.println(message...); in server.xml I set : Logger className=org.apache.catalina.logger.FileLogger verbosity=4 directory=logs prefix=localhost_log. suffix=.txt timestamp=true/ Now, Instead of save the message on stdout.log I would like to store all message on localhost_log.-MM-DD.txt, beacause the stdout.log it's become too large. How can i solve this issue? Thanks Franz. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: jdk1.4 tomcat5 log4j finds java.util.logging Logger not l og4j
my imports are import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; is that the problem? maybe when the author wrote these examples he was running jdk1.3 so it was not an issue, but running under 1.4 seems to find jdk1.4 logging thanks for any help, just tryin to get a handle on whats happening -Original Message- From: D'Alessandro, Arthur [mailto:[EMAIL PROTECTED] Sent: Friday, April 09, 2004 5:37 PM To: Tomcat Users List; [EMAIL PROTECTED] Subject: RE: jdk1.4 tomcat5 log4j finds java.util.logging Logger not log4j What are your imports? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Fri Apr 09 16:58:08 2004 To: [EMAIL PROTECTED] Subject:jdk1.4 tomcat5 log4j finds java.util.logging Logger not log4j hi all I am running tomcat 5, with jdk 1.4 and have not changed any of the jar directories (server/lib or common/lib) by adding my log4j.jar and the problem is when I got log, it is finding the jdk1.4 logging and not log4j. I have do log4j.jar in my WEB-INF/lib below is my init log4j init servlet and snippet of web.xml, all seems fine in the 1st servlet I hit, i do a private Log log = LogFactory.getLog(this.getClass().getName()); and then a print which Logger i am using and it shows java.util.logging.Logger System.out.println(* log= +log); which yields [EMAIL PROTECTED] and then System.out.println(* log.getLogger() = +((org.apache.commons.logging.impl.Jdk14Logger)log).getLogger()); which yields log.getLogger() [EMAIL PROTECTED] How can I get it to use log4j, i dropped log4j.jar in myapp/WEB-INF/lib/ and thought that would be enough any suggestions, and thanks for the help, Happy Easter this is an example from Struts Framework book (Switchback Software LLC), almost exact so I thought it should work === public class Log4jInitServlet extends HttpServlet { public void init() { String prefix = getServletContext().getRealPath(/); String file = getInitParameter(log4j-init-file); log(prefix+file= +prefix+file); if (file != null) { PropertyConfigurator.configure(prefix+file); } else { BasicConfigurator.configure(); } } public void doGet(HttpServletRequest req, HttpServletResponse res) { } } and web.xml --- servlet servlet-namelog4j-init/servlet-name servlet-classcdmanager.Log4jInitServlet/servlet-class init-param param-namelog4j-init-file/param-name param-valueWEB-INF\log4j.properties/param-value /init-param load-on-startup1/load-on-startup /servlet and my log4j.properties --- # Set root category priority to DEBUG and its only appender to A1. log4j.rootCategory=DEBUG,A1,F1 log4j.category.cdmanager=DEBUG,A1,F1 # A1 is set to be a ConsoleAppender. log4j.appender.A1=org.apache.log4j.ConsoleAppender # A1 uses PatternLayout. log4j.appender.A1.layout=org.apache.log4j.PatternLayout # log4j.appender.A1.layout.ConversionPattern=%d %-4r [%t](%F:%L) %-5p %c %x - %m%n log4j.appender.A1.layout.ConversionPattern=%d [%t](%F:%L) %-5p %x - %m%n # F1 is set to be a RollingFileAppender that uses PatternLayout, add F1 # to the desired categories to enable file trace log4j.appender.F1=org.apache.log4j.RollingFileAppender log4j.appender.F1.layout=org.apache.log4j.PatternLayout log4j.appender.F1.layout.ConversionPattern=%p %t %c - %m%n log4j.appender.F1.File=D:\\Tomcat5.0\\logs\\mylog.log log4j.appender.F1.MaxFileSize=100KB log4j.appender.F1.MaxBackupIndex=1 log4j.category.org=WARN,A1,F1 - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
jdk1.4 tomcat5 log4j finds java.util.logging Logger not log4j
hi all I am running tomcat 5, with jdk 1.4 and have not changed any of the jar directories (server/lib or common/lib) by adding my log4j.jar and the problem is when I got log, it is finding the jdk1.4 logging and not log4j. I have do log4j.jar in my WEB-INF/lib below is my init log4j init servlet and snippet of web.xml, all seems fine in the 1st servlet I hit, i do a private Log log = LogFactory.getLog(this.getClass().getName()); and then a print which Logger i am using and it shows java.util.logging.Logger System.out.println(* log= +log); which yields [EMAIL PROTECTED] and then System.out.println(* log.getLogger() = +((org.apache.commons.logging.impl.Jdk14Logger)log).getLogger()); which yields log.getLogger() [EMAIL PROTECTED] How can I get it to use log4j, i dropped log4j.jar in myapp/WEB-INF/lib/ and thought that would be enough any suggestions, and thanks for the help, Happy Easter this is an example from Struts Framework book (Switchback Software LLC), almost exact so I thought it should work === public class Log4jInitServlet extends HttpServlet { public void init() { String prefix = getServletContext().getRealPath(/); String file = getInitParameter(log4j-init-file); log(prefix+file= +prefix+file); if (file != null) { PropertyConfigurator.configure(prefix+file); } else { BasicConfigurator.configure(); } } public void doGet(HttpServletRequest req, HttpServletResponse res) { } } and web.xml --- servlet servlet-namelog4j-init/servlet-name servlet-classcdmanager.Log4jInitServlet/servlet-class init-param param-namelog4j-init-file/param-name param-valueWEB-INF\log4j.properties/param-value /init-param load-on-startup1/load-on-startup /servlet and my log4j.properties --- # Set root category priority to DEBUG and its only appender to A1. log4j.rootCategory=DEBUG,A1,F1 log4j.category.cdmanager=DEBUG,A1,F1 # A1 is set to be a ConsoleAppender. log4j.appender.A1=org.apache.log4j.ConsoleAppender # A1 uses PatternLayout. log4j.appender.A1.layout=org.apache.log4j.PatternLayout # log4j.appender.A1.layout.ConversionPattern=%d %-4r [%t](%F:%L) %-5p %c %x - %m%n log4j.appender.A1.layout.ConversionPattern=%d [%t](%F:%L) %-5p %x - %m%n # F1 is set to be a RollingFileAppender that uses PatternLayout, add F1 # to the desired categories to enable file trace log4j.appender.F1=org.apache.log4j.RollingFileAppender log4j.appender.F1.layout=org.apache.log4j.PatternLayout log4j.appender.F1.layout.ConversionPattern=%p %t %c - %m%n log4j.appender.F1.File=D:\\Tomcat5.0\\logs\\mylog.log log4j.appender.F1.MaxFileSize=100KB log4j.appender.F1.MaxBackupIndex=1 log4j.category.org=WARN,A1,F1 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]