In my GAE/J application, how would I configure the default logger to report errors via email?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
An SMTPHandler already exists, but cannot be used with GAE/J because of unsatisfied dependencies. Take a look at the source code of SMTPHandler and adapt it to GAE/J.
The MailHandler included with JavaMail 1.5.3 and later have built in support for Google App Engine. Make sure you are using the most current version of JavaMail.
For GAE/J you can download the logging-mailhandler.jar and include it in your project.
Otherwise, can use the java.net Maven repository or Maven Central and pull the dependency by groupid=com.sun.mail and artifactId=logging-mailhandler.
After the dependency is setup, then configure your logging.properties to contain the correct log settings and email envlope. Here is a sample logging.properties file:
Next create code to install the MailHandler because the LogManager won't be able to see the logging-mailhandler.jar.
Here is an example of a ServletContextListener that will install the MailHandler on the root logger.