通过apache tomcat服务器启动中的电子邮件发送错误和异常 [英] sending errors and exceptions through emails in apache tomcat server start

查看:115
本文介绍了通过apache tomcat服务器启动中的电子邮件发送错误和异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用apache-tomcat-7.0.25并在系统上启动了本地实例. 我必须通过电子邮件将错误和异常发送给我在日志文件中找到的各个人. 我有配置文件server.xml,web.xml,tomcat-users.xml,context.xml,catalina.properties文件以及logging.properties文件.

I have used apache-tomcat-7.0.25 and started a local instance on my system. i have to send errors and exceptions through emails to various people which i have found in the log files. i have the config files server.xml , web.xml, tomcat-users.xml , context.xml , catalina.properties files and also a logging.properties file.

logging.properties文件由以下代码组成.

the logging.properties file consists of the following code.

handlers = 1catalina.org.apache.juli.FileHandler, \
           2localhost.org.apache.juli.FileHandler, \
           3manager.org.apache.juli.FileHandler, \
           java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.

2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.

3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
3manager.org.apache.juli.FileHandler.bufferSize = 16384

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter


############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = \
   2localhost.org.apache.juli.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = \
   3manager.org.apache.juli.FileHandler

# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE

在出现任何错误或异常时如何将其重定向到邮件?

How to redirect it to a mail when there is any error or exceptions?

推荐答案

免责声明:我是对于java.util.logging,您可以使用 JavaMail 附带的nofollow noreferrer> MailHandler .

For java.util.logging you can use MailHandler included with JavaMail.

  1. 下载 JavaMail 参考实现jar文件(javax.mail.jar). /li>
  2. 在Tomcat引导程序中修改包含JavaMail的tomcat启动脚本 ClassLoader.
  3. 修改logging.properties 文件以安装MailHandler和任何支持的类.
  1. Download the JavaMail reference implementation jar file (javax.mail.jar).
  2. Modify the tomcat startup script include JavaMail in the Tomcat bootstrap ClassLoader.
  3. Modify the logging.properties file to install the MailHandler and any supporting classes.

这是一个示例配置:

handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler, com.sun.mail.util.logging.MailHandler

.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler, com.sun.mail.util.logging.MailHandler


com.sun.mail.util.logging.MailHandler.subject=com.sun.mail.util.logging.CollectorFormatter
#com.sun.mail.util.logging.CollectorFormatter.format=Tomcat:{0}{1}{2}{4,choice,-1#|0#|0<... {4,number,integer} more}
#com.sun.mail.util.logging.CompactFormatter.format=[%4$-7.7s] %7$#.140s
com.sun.mail.util.logging.MailHandler.level=WARNING
com.sun.mail.util.logging.MailHandler.filter=com.sun.mail.util.logging.DurationFilter
com.sun.mail.util.logging.MailHandler.pushLevel=WARNING
com.sun.mail.util.logging.MailHandler.mail.host=some-smtp-host
#com.sun.mail.util.logging.MailHandler.mail.user=some-user
#com.sun.mail.util.logging.MailHandler.authenticator=some-password
com.sun.mail.util.logging.MailHandler.mail.from=app@server.com
#com.sun.mail.util.logging.MailHandler.mail.sender=team@list.com
com.sun.mail.util.logging.MailHandler.mail.to=devs@bugfixers.com
com.sun.mail.util.logging.MailHandler.verify=resolve
com.sun.mail.util.logging.MailHandler.mail.smtp.quitwait=false
com.sun.mail.util.logging.MailHandler.mail.smtps.quitwait=false
com.sun.mail.util.logging.MailHandler.mail.smtp.connectiontimeout=45000
com.sun.mail.util.logging.MailHandler.mail.smtps.connectiontimeout=45000
com.sun.mail.util.logging.MailHandler.mail.smtp.timeout=45000
com.sun.mail.util.logging.MailHandler.mail.smtps.timeout=45000

这篇关于通过apache tomcat服务器启动中的电子邮件发送错误和异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆