电子邮件日志文件,由 Java WebLogic 应用程序服务器生成
这个要求符合J2EE标准吗? 有没有一种简单的方法来实现这一点,日志文件由 Log4J 生成,最后我将访问文件系统并通过电子邮件发送整个文件。 我可以访问文件系统吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Log4j 有一个电子邮件附加程序...
请参阅:http://www.onjava.com/pub/a/onjava/2004/09/29/smtp-logging.html?page=2
(另请参阅第 1 页)
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)
使用 log4j,您可以将电子邮件附加程序添加到您的配置中。 您可以在 log4j.proeprties 中声明附加程序:
log4j.appender.email=org.apache.log4j.net.SMTPAppender
log4j.appender.email.To= #recepient 的电子邮件地址
log4j.appender.email.From= #发件人的电子邮件地址
log4j.appender.email.SMTPHost= #您的 smtp 服务器的位置
log4j.appender.email.Threshold=FATAL #生成电子邮件的最低日志级别
log4j.appender.email.BufferSize=512
log4j.appender.email.Subject= #发出的电子邮件的主题行
log4j.appender.email.layout=org.apache.log4j.PatternLayout
log4j.appender.email.layout.ConversionPattern=-[%d] %-4L %-5p %c %x - %m%n #message format
需要记住的事情:此附加程序将在满足以下条件的每条日志消息上发送一封电子邮件阈值要求,因此建议设置较高的阈值,这样您的收件箱就不会被不重要的消息淹没。
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.