Email report appender

It is possible to activate an email report handler if you want more advanced reporting than is provided by the reporting feature accessible through the Opinio setup screen. When activated, the appender can report all types of events, not just database connection errors. All events written to the log will trigger the appender to check if you should be notified. The feature is configurable by setting the email report appender attributes in the log4j properties file (opinio/WEB-INF/log4j.properties).

log4j.properties configuration:

  1. Invoke the email appender by adding it to the rootLogger attribute at the top of the file:

    log4j.rootLogger=info, R, emailReport

  2. Uncomment the emailReport attributes. Only uncomment the username and password attributes if mail server requires authentication.

  3. Set the options:

    • Set to and from address and mail server:

      log4j.appender.emailReport.From=<from address>

      log4j.appender.emailReport.To=<to address>

      log4j.appender.emailReport.SMTPHost=<mail server>

    • Set triggering level. The default is ERROR which triggers on error and fatal events. Another recommended level is FATAL which only triggers on the critical errors. When a triggering event occurs, the appender checks if a report should be send by email. Whether an email is send or not is affected by the time interval since last error mail and the interval attribute.

      log4j.appender.emailReport.triggeringLevel=ERROR

    • Set minimum interval between mails in minutes. A mail will be sent on the first occurrence of a triggering event. Then a new mail will not be sent before the interval time has elapsed. Events occurring during the interval period are stored in a queue system. The first triggering event that happens after the interval has elapsed includes the events from the queue. The queue contains the five first and five last events reported in that period. If the interval is set to 60, the default, you will receive maximum one email per hour.

      log4j.appender.emailReport.interval=60

    • Set layout: The layout can be configured according to the log4j manual, but it is recommended to keep the defaults.

      log4j.appender.emailReport.layout=org.apache.log4j.PatternLayout

      log4j.appender.emailReport.layout.conversionPattern=%d %-5p [%-10t] %c{2} - %m%n

    • Set authentication details if your email servers requires authentication. Only uncomment these attributes if it is needed.

      log4j.appender.emailReport.UserName=<mail server username>

      log4j.appender.emailReport.Password=<mail server password>