mime types - java mail logs html template to catalina.out -


i using velocity generate html template based content email sent, , java mail api spring's mimemessagehelper send emails. problem facing while rendering, html template thrown catalina.out making file grow in size , not desirable.

i have separate application log file logs generated. there way can redirect rendering application log file? or may can stop thrown @ catalina.out.

below details gets written while sending email

loading javamail.default.providers jar:file:/d:/workspace/emailservice/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/email-service/web-inf/lib/mail-1.4.jar!/meta-inf/javamail.default.providers debug: loading new provider protocol=imap, classname=com.sun.mail.imap.imapstore, vendor=sun microsystems, inc, version=null debug: loading new provider protocol=imaps, classname=com.sun.mail.imap.imapsslstore, vendor=sun microsystems, inc, version=null debug: loading new provider protocol=smtp, classname=com.sun.mail.smtp.smtptransport, vendor=sun microsystems, inc, version=null debug: loading new provider protocol=smtps, classname=com.sun.mail.smtp.smtpssltransport, vendor=sun microsystems, inc, version=null debug: loading new provider protocol=pop3, classname=com.sun.mail.pop3.pop3store, vendor=sun microsystems, inc, version=null debug: loading new provider protocol=pop3s, classname=com.sun.mail.pop3.pop3sslstore, vendor=sun microsystems, inc, version=null debug: getprovider() returning provider protocol=smtp; type=javax.mail.provider$type@2025b64d; class=com.sun.mail.smtp.smtptransport; vendor=sun microsystems, inc debug smtp: useehlo true, useauth true debug smtp: trying connect host "smtp.nagarro.com", port 587, isssl false  220 fuseout2c mailanyone extsmtp tue, 23 jul 2013 02:37:58 -0700 debug smtp: connected host "smtp.nagarro.com", port: 587  ehlo vaibhav202001  250-fuseout2c hello vaibhav202001 [14.141.12.161]  250-size 52428800  250-pipelining  250-auth login  250-starttls 250 debug smtp: found extension "size", arg "52428800" debug smtp: found extension "pipelining", arg "" debug smtp: found extension "auth", arg "login" debug smtp: found extension "starttls", arg "" debug smtp: found extension "help", arg "" starttls 220 tls go ahead ehlo vaibhav202001 250-fuseout2c hello vaibhav202001 [14.141.12.161] 250-size 52428800 250-pipelining 250-auth login 250 debug smtp: found extension "size", arg "52428800" debug smtp: found extension "pipelining", arg "" debug smtp: found extension "auth", arg "login" debug smtp: found extension "help", arg "" debug smtp: attempt authenticate auth login 334 vxnlcm5hbwu6 annhzy5zdxbwb3j0qg5hz2fycm8uy29t 334 ugfzc3dvcmq6 snnhz0axmjm0 235 authentication succeeded debug smtp: use8bit false mail from:<jsagteam@nagarro.com> 250 ok rcpt to:<vaibhav.shukla@nagarro.com> 250 accepted debug smtp: verified addresses debug smtp:   vaibhav.shukla@nagarro.com data 354 enter message, ending "." on line date: fri, 26 jul 2013 12:00:48 +0530 (ist) from: jsag team <jsagteam@nagarro.com> to: vaibhav.shukla@nagarro.com message-id: <1817391686.01374820248531.javamail.vaibhav2020@vaibhav202001> subject: jsag home page - subscribers list mime-version: 1.0 content-type: multipart/mixed;  boundary="----=_part_0_999692932.1374820244866"  ------=_part_0_999692932.1374820244866 content-type: multipart/related;  boundary="----=_part_1_1241615899.1374820244889"  ------=_part_1_1241615899.1374820244889 content-type: text/html; charset=us-ascii content-transfer-encoding: 7bit             //my email template goes here  ------=_part_1_1241615899.1374820244889--  ------=_part_0_999692932.1374820244866--   250 ok id=1v1z2g-0002rh-ho quit 221 fuseout2c closing connection 

and here logging configuration

log4j.appender.file=org.apache.log4j.rollingfileappender log4j.appender.file.file=${catalina.home}/logs/email-service.log log4j.appender.file.maxfilesize=1000kb log4j.appender.file.maxbackupindex=1 log4j.appender.file.layout=org.apache.log4j.patternlayout log4j.appender.file.layout.conversionpattern=%d{yyyy-mm-dd hh:mm:ss} %-4p %m%n log4j.appender.datepattern='.'yyyy-mm-dd  # root logger option log4j.rootlogger=warn, file log4j.logger.com.nagarro=warn 

also code send email

javamailsender mailsender; // injected through spring di  /**  * mail message.  */ simplemailmessage mailmessage; // spring di  @override public void sendemail(final emailservicerequest request, byte[] data) {     mimemessage message = mailsender.createmimemessage();     outputstream outstream = null;     try {          mimemessagehelper helper = new mimemessagehelper(message, true);           // set attributes         if (null != request.getrecipientemailid()) {             helper.setto(request.getrecipientemailid());         }         helper.setfrom(request.getsenderemailid());         helper.setsubject(request.getsubject());         helper.settext(request.getcontent(), true);          // check recipient list         if (null != request.getrecipients() && !request.getrecipients().isempty()) {             internetaddress[] recipients = new internetaddress[request.getrecipients().size()];              (int index = 0; index < request.getrecipients().size(); index++) {                 recipients[index] = new internetaddress(request.getrecipients().get(index));             }             helper.setto(recipients);         }          // data handler         if (null != data) {             try {                  file file = file.createtempfile(request.getattachmentname(), "");                 outstream = new fileoutputstream(file);                 outstream.write(data);                  helper.addattachment(request.getattachmentname(), file);             } catch (ioexception e) {                 logger.error(e.getmessage(), e);             } {                 try {                     outstream.flush();                     outstream.close();                 } catch (ioexception e) {                     logger.error(e.getmessage(), e);                 }             }         }          if (!stringutil.isnullorempty(request.getemailidcc())) {             helper.addcc(request.getemailidcc());         }         if (!stringutil.isnullorempty(request.getemailidbcc())) {             helper.addbcc(request.getemailidbcc());         }          mailsender.send(message);     } catch (messagingexception e) {         logger.error(e.getlocalizedmessage(), e);     } } 

i assume have defined bean class org.springframework.mail.javamail.javamailsenderimpl in context configuration.

if so, try set debug property on session.

mailsender.getsession().setdebug(false); 

or create properties file , set set value there.

mail.debug=false 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -