You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stephane-3 <mi...@yahoo.se> on 2012/02/06 08:25:07 UTC

Build on test target hangs when using an SMTP appender in the log4j configuration

Hi,

In my log4j.xml file if I have the following line:

		<appender-ref ref="mailAppender" />

as in:

	<root>
		<appender-ref ref="mailAppender" />
	</root>

with the following appender:

	<appender name="mailAppender" class="org.apache.log4j.net.SMTPAppender">
		
		
		
		
		
		
		
		
		<layout class="org.apache.log4j.PatternLayout">
			
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			
			
		</filter>
	</appender>

then the build hangs.

The console output just stops dead and I don't get the prompt back.

>From this article 
http://magnus-k-karlsson.blogspot.com/2010/02/sending-log-errors-with-log4j-and.html
I also added an smtp.properties file containing:

mail.smtp.port=465
mail.smtp.socketFactory.port=465
mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.fallback=false

and being parsed by a Maven filter:

        <filters>
          <filter>src/main/filters/data-source.properties</filter>
          <filter>src/main/filters/smtp.properties</filter>
        </filters>

But it did not help.

Here is the complete log4j.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM
&quot;org/apache/log4j/xml/log4j.dtd&quot;>

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
	debug="false">

	<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
		
		<layout class="org.apache.log4j.PatternLayout">
			
		</layout>
	</appender>

	<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
		
		
		
		
		<layout class="org.apache.log4j.PatternLayout">
			
		</layout>
	</appender>

	<appender name="mailAppender" class="org.apache.log4j.net.SMTPAppender">
		
		
		
		
		
		
		
		
		<layout class="org.apache.log4j.PatternLayout">
			
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			
			
		</filter>
	</appender>

	<appender name="sqlAppender" class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
			
		</layout>
	</appender>

	<category name="org.springframework" additivity="false">
		<appender-ref ref="consoleAppender" />
	</category>

	<category name="com.thalasoft" additivity="false">
		<appender-ref ref="consoleAppender" />
	</category>

	<category name="org.hibernate.type" additivity="false">
        <level value="ALL" />
		<appender-ref ref="sqlAppender" />
	</category>

	<root>
		<appender-ref ref="fileAppender" />
		<appender-ref ref="mailAppender" />
	</root>

</log4j:configuration>

Stephane

--
View this message in context: http://maven.40175.n5.nabble.com/Build-on-test-target-hangs-when-using-an-SMTP-appender-in-the-log4j-configuration-tp5459477p5459477.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Build on test target hangs when using an SMTP appender in the log4j configuration

Posted by Stephane-3 <mi...@yahoo.se>.
Hi Wayne,

In fact it was a strange java behavior. 

After rebooting my pc Lenovo X60 with Linux Mint 12 the build worked fine.

The mails were sent containing the exceptions.

The issue is closed.

Thanks.



--
View this message in context: http://maven.40175.n5.nabble.com/Build-on-test-target-hangs-when-using-an-SMTP-appender-in-the-log4j-configuration-tp5459477p5656684.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Build on test target hangs when using an SMTP appender in the log4j configuration

Posted by Wayne Fay <wa...@gmail.com>.
> So I removed the file spring-smtp-appender.xml
...lots of lines of Spring configuration...
...brief mention of dependendencies...
> But the issue remains the same and the build hangs.

I don't think you're getting any traction on your questions here
because this is not the right place to ask this question.

Ask for help @ Spring list/forum. Maven has very little to do with your issue.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Build on test target hangs when using an SMTP appender in the log4j configuration

Posted by Stephane-3 <mi...@yahoo.se>.
So I removed the file spring-smtp-appender.xml

Then I added a debug property:

		

as in:

	<appender name="mailAppender" class="org.apache.log4j.net.SMTPAppender">
		

I also added the port property:

		

When I then ran the build I could see the following output in the console
log:

DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL
false

But the SSL should be ttrue for the gmail smtp.

Here is what Google requires:

Server: smtp.gmail.com
Port: 465
Connection secutiry: SSL
Authentication: Normal password

So I googled and found out about the SSL property and added it:

		

The full smtp appender now looks like:

	<appender name="mailAppender" class="org.apache.log4j.net.SMTPAppender">
		
		
		
		
		
		
		
		
		
		
		
		<layout class="org.apache.log4j.PatternLayout">
			
		</layout>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			
			
		</filter>
	</appender>

I'm also using slf4j instead of log4j as:

      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.4</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.4</version>
      </dependency>

But the issue remains the same and the build hangs.



--
View this message in context: http://maven.40175.n5.nabble.com/Build-on-test-target-hangs-when-using-an-SMTP-appender-in-the-log4j-configuration-tp5459477p5656537.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org