views:

220

answers:

2

does this requirement conform to the J2EE Standards? is there a easy way to implement this, log file gets generated by Log4J and in the end I will access the file system and email the whole file(s). can I access the file system?

+1  A: 

Log4j has an email appender...

See: http://www.onjava.com/pub/a/onjava/2004/09/29/smtp-logging.html?page=2 (Also look on page 1)

GreenieMeanie
A: 

with log4j, you can add an email appender to your configuration. You can declare the appender in your log4j.proeprties so:

log4j.appender.email=org.apache.log4j.net.SMTPAppender log4j.appender.email.To= #recepient's email address log4j.appender.email.From= #the sender's email address log4j.appender.email.SMTPHost= #location of your smtp server log4j.appender.email.Threshold=FATAL #the lowest log level on which the email is generated log4j.appender.email.BufferSize=512 log4j.appender.email.Subject= #subject line of the email sent out log4j.appender.email.layout=org.apache.log4j.PatternLayout log4j.appender.email.layout.ConversionPattern=-[%d] %-4L %-5p %c %x - %m%n #message format

Something to remember: this appender will send an email on every log message that meets the threshold requirement so having a high threshold is recommended so your inbox doesn't get flooded with messages that are non critical.

neesh