Re: SMTPAppender not asynchronous using AsyncAppender
It is not working for me as well. I am making use of a customized SMTPAppender class for my application purposes. It is not even entering this class. If I remove async way, it is working fine. With async enabled, if I give the mailhost wrongly, no exception is thrown back. Please help Here is my log4j xml: ?xml version=1.0 encoding=UTF-8? !DOCTYPE log4j:configuration SYSTEM log4j.dtd !-- | For more configuration infromation and examples see the Jakarta Log4j | owebsite: http://jakarta.apache.org/log4j -- log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; debug=true !-- Buffer events and log them asynchronously -- appender name=ASYNC class=org.apache.log4j.AsyncAppender appender-ref ref=MAIL / /appender !-- EMail events to an administrator -- appender name=MAIL class=com.mycomp.notification.log4j.SMTPAppenderTimeout layout class=org.apache.log4j.HTMLLayout / /appender root priority value =FATAL / appender-ref ref=ASYNC / /root /log4j:configuration Thanks, Radhika. alkuin wrote: amitshinde wrote: Did anyone else notice this? Can we send emails asynchronously at all? I am using log4j-1.2.15 in Tomcat 5.5. Sending emails asynchronously seems to work with an appender-ref ref=async/ in the root and an appender-ref ref=mail/ in the async appender. mail is the name of the SMTPAppender. To check if email is sent asynchronously, I provoked an error by giving a wrong SMTPPassword in the configuration. In Tomcat's log directory, the stdout_20090203.log then contained this stack trace: javax.mail.AuthenticationFailedException at javax.mail.Service.connect(Service.java:306) at javax.mail.Service.connect(Service.java:156) at javax.mail.Service.connect(Service.java:105) at javax.mail.Transport.send0(Transport.java:168) at javax.mail.Transport.send(Transport.java:98) at org.apache.log4j.net.SMTPAppender.sendBuffer(SMTPAppender.java:330) at org.apache.log4j.net.SMTPAppender.append(SMTPAppender.java:215) at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251) at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66) at org.apache.log4j.AsyncAppender$Dispatcher.run(AsyncAppender.java:583) at java.lang.Thread.run(Unknown Source) Without the AsyncAppender, the stack trace was like this: javax.mail.AuthenticationFailedException at javax.mail.Service.connect(Service.java:306) at javax.mail.Service.connect(Service.java:156) at javax.mail.Service.connect(Service.java:105) at javax.mail.Transport.send0(Transport.java:168) at javax.mail.Transport.send(Transport.java:98) at org.apache.log4j.net.SMTPAppender.sendBuffer(SMTPAppender.java:330) at org.apache.log4j.net.SMTPAppender.append(SMTPAppender.java:215) at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251) at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66) at org.apache.log4j.Category.callAppenders(Category.java:206) at org.apache.log4j.Category.forcedLog(Category.java:391) at org.apache.log4j.Category.error(Category.java:322) at org.apache.jsp.errorhandler_jsp._jspService(errorhandler_jsp.java:86) (truncated; many more lines following) -- View this message in context: http://old.nabble.com/SMTPAppender-not-asynchronous-using-AsyncAppender-tp21308582p32643700.html Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Log4j and Tomcat with multiple instances
Here's what I do, which is a bit different from the Tomcat instructions. I pretty much ignore #5 in their instructions 1. Modify $CATALINA_BASE/conf/catalina.properties. Change the single line... common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar ...to... common.loader=${catalina.base}/shared,${catalina.base}/shared/*.jar,${catalina.home}/shared,${catalina.home}/shared/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar I usually also modify $CATALINA_HOME/catalina.properties with the following, but you can skip this step if you never run Tomcat without using a separate CATALINA_BASE... common.loader=${catalina.home}/shared,${catalina.home}/shared/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar 2. Place log4j.jar and log4j.properties in ${catalina.home}/shared (create the directory if it doesn't exist). You can always override this per/instance by placing log4j.properties in ${catalina.base}/shared, but the default one will always be there and all instances can share log4j.jar from $CATALINA_HOME. Make sure log4j.properties references ${catalina.base} (as in Tomcat's' documentation) instead of ${catalina.home}. 3. Replace $CATALINA_HOME/bin/tomcat-juli.jar with tomcat-juli.jar from extras and put tomcat-juli-adapters.jar from extras into $CATALINA_HOME/lib or $CATALINA_HOME/shared That's about it. Hope I didn't miss anything. I'm kind of doing this from memory. Jake On Thu, 13 Oct 2011 16:49:31 +0200 Peter Magnusson pet.magnus...@gmail.com wrote: Hi, I have a problem with log4j. Im to set up log4j with tomcat and a basic setup works fine. Our setup is that we have multiple instances of Tomcat running on different ports with different $CATALINA_BASE but the same $CATALINA_HOME, we set this up to be able to start and stop applications independent from each other. If i set everything up as described here http://tomcat.apache.org/tomcat-6.0-doc/logging.html#Using_Log4j (disregard #5) it works fine, only problem is that all instances of tomcat log to the same file. This is not what i want, i want each instance of tomcat to log to its own logfile. So i changed my setup accordning to #5 here http://tomcat.apache.org/tomcat-6.0-doc/logging.html#Using_Log4j , but i cannot get this to work at all. Its not logging anything when its setup like this. First of all, is what im trying to achieve even possible ? If so, any idea what im doing wrong ? How can i troubleshoot this ? Any ideas are most welcome, thank you! Best regards Peter - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: SMTPAppender not asynchronous using AsyncAppender
If an uncaught exception occurs on the worker thread in AsyncAppender and the worker thread dies, then AsyncAppender will fall back to synchronous behavior. Possibly, you are seeing this synchronous behavior after death of the AsyncAppender worker thread. On Jan 6, 2009, at 5:12 AM, amitshinde wrote: Hello Everyone, I am trying to send asynchronous error emails using log4j. I was successfully able to get the emails but it looks like the emails are synchronous and block the event processing till the email is sent. This happens inspite of using AsyncAppender. I am using SMTPAppender and hooked it up with AsyncAppender (appender-ref ref=mail/) Did anyone else notice this? Can we send emails asynchronously at all? Thanks in advance, Amit -- View this message in context: http://www.nabble.com/SMTPAppender-not-asynchronous-using-AsyncAppender-tp21308582p21308582.html Sent from the Log4j - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org