tags:

views:

193

answers:

1

Hi

I am trying to setup a smtpappender for log4j using gmail as the smtp host.

I have read that the port number needs to be 465 or 587 (depending on tls or ssl) and that log4j for some reason doesnt allow a different port to be set inside log4j.properties configuration file.

I have read that the best way of doing this would be to use System.setProperty which would change the default javaxmail port to gmail.

However when I try to set the System.property entries the the default port still remains as 25

System.setProperty("mail.smtp.starttls.enable", "true"); System.setProperty("mail.smtp.port", "587");

I was wondering if someone could help me out, I am open to suggestions, I just need to smtpAppender to work for gmail, dont really care how to get it to work.

Thanks

+1  A: 

You need to create a custom SMTPAppender and specify it in the log4j config file. Google learns me that there are at least two blog posts which describes how to do it: here and here.

BalusC