You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by amitshinde <am...@amicontech.com> on 2009/01/06 12:12:12 UTC

SMTPAppender not asynchronous using AsyncAppender

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-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: SMTPAppender not asynchronous using AsyncAppender

Posted by Radhika81 <ra...@gmail.com>.
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-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: SMTPAppender not asynchronous using AsyncAppender

Posted by alkuin <ak...@web.de>.

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://www.nabble.com/SMTPAppender-not-asynchronous-using-AsyncAppender-tp21308582p21814330.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: SMTPAppender not asynchronous using AsyncAppender

Posted by Curt Arnold <ca...@apache.org>.
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-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org