RE: [SPAM (Bayesain Analysis)] - Newbie help: Capturing Stdout and Stderr into log4j - Bayesian Filter detected spam
Log4j is not designed for hooking any system event. It's mainly a very flexible output channel. Capturing the stdout: Assign your own OutputStream to System.out and you get all messages to stdout. These you can write then to any logger you wish. Exceptions are catched in the normal java way through try..catch. Within the catch block you would typically write myLog.error( Exception catched in method XY, e ); Heri -Original Message- From: enthucoder [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 28, 2007 11:46 PM To: log4j-user@logging.apache.org Subject: [SPAM (Bayesain Analysis)] - Newbie help: Capturing Stdout and Stderr into log4j - Bayesian Filter detected spam Hi, I am relatively new to log4j. Can anybody help me guiding towards the best practice to achieve following? 1.) How would i capture the Std out messages into log4j? (or is it anything different than just embedding messages one wants to print into logger() method?) 2.) Also there would be some exceptions or errors (would be the right term I guess) which are unexpected like NullPointerException etc, which usually leaked. How would one go about capturing these? Thanks in advance. .H -- View this message in context: http://www.nabble.com/Newbie-help%3A-Capturing-Stdout-and-Stde rr-into-log4j-tf4893246.html#a14013050 Sent from the Log4j - Users mailing list archive at Nabble.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]
JSF/Struts logs ok Servlet/JSP does not?
I have a JSF app, a struts app and a Servlet/JSP app running in the same Tomcat 5.5 server. The JSF and Servlet app initialize and run log4j with no problems. The Servlet/JSP app does not initialize log4j. I am running Tomcat with -Dlog4j.debug set. The init method of the initial servlet loaded on startup, the log4j.properties file and the Tomcat stdout log are below: init method ... // props is the path to the log4j.properties file PropertyConfigurator.configure(props); Logger log = Logger.getRootLogger(); log.debug(Logger Works); ## log4j.properties file # Global logging configuration log4j.rootLogger=DEBUG, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n ## stdout Tomcat log with -Dlog4j.debug set ... -- Parent Classloader: [EMAIL PROTECTED] . log4j: Using URL [file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapp s/ecr/WEB-INF/classes/log4j.properties] for automatic log4j configuration. log4j: Reading configuration from URL file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps /ecr/WEB-INF/classes/log4j.properties log4j: Could not find root logger information. Is this OK? log4j: Finished configuring. log4j: Could not find root logger information. Is this OK? log4j: Finished configuring. log4j:WARN No appenders could be found for logger (com.ecr.servlets.SetupServlet). log4j:WARN Please initialize the log4j system properly. ### My JSF and Struts apps have an identical copy of the log4j.properties file as the Servlet/JSP app and it is located in the same place WEB-INF/classes. And, all three apps are useing the same version of log4j version 1.2.8. The only thing I can think of is that I am not initializing my Servlet/JSF log4j correctly the same way JSF and Struts are. What do I need to do to make it work? Thanks, Warren - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]