This post shows how you can setup log4j to send email when errors occur in your application. log4j.properties extract:
# Root category priority: DEBUG, Appender:mail log4j.rootCategory=debug, mail # Configuration for receiving e-mails when ERROR messages occur. log4j.appender.mail=org.apache.log4j.net.SMTPAppender log4j.appender.mail.To=admin@company.com log4j.appender.mail.From=error@application-name.com log4j.appender.mail.SMTPHost=smtp.company.com log4j.appender.mail.Threshold=ERROR log4j.appender.mail.BufferSize=1 log4j.appender.mail.Subject=Application Error Occurred log4j.appender.mail.layout=org.apache.log4j.HTMLLayout
February 14, 2008 at 3:10 am |
Hi,
Thanks for the information. Does the application look into the log4j.properties file automatically when there is an exception/error or is there any configuration to be set for this. Please mail me immediately at findgsk@gmail.com
February 27, 2009 at 10:07 am |
Hey,
What if SMTP server require authentication. Where to define user name and password?
Thanks in advanced