The IdP uses a logging "facade" called slf4j to allow the logging implementation to be replaced if desired. By default, logging is handled with the Logback library, which offers a lot of advanced capabilities for deployers. This page includes suggestions for how to make the logging layer more useful and we welcome additions by deployers to document the tricks they employ.
Logback can be configured to perform various actions when different conditions are satisfied, one of which is using SMTP to deliver log data. This example will configure Logback to send an email any time an event level of ERROR is generated. All log data will still be written to the default FILE appender also.
Even logging on only ERROR conditions can generate plenty of mail, so this trick is best employed in conjunction with additional changes not shown here, such as message filtering.
For reference:
There are two parts to configure:
When configuring data values in the appender, staying as generic as possible allows the same logback.xml to be used among dev, test, and production environments without any modifications (always a plus when you're being audited).
<level> : What condition to take action on (DEBUG, INFO, WARN, ERROR)
<!-- Custom SMTP Appender for ERROR --> <appender name="Email_Alerts" class="ch.qos.logback.classic.net.SMTPAppender"> <smtpHost>SMTPHOSTNAME</smtpHost> <from>FROMEMAILADDRESS</from> <to>TOEMAILADDRESS</to> <subject>${HOSTNAME} IDP Error Detected</subject> <layout class="ch.qos.logback.classic.html.HTMLLayout"/> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>ERROR</level> </filter> </appender> <!-- /Custom SMTP Appender for ERROR --> |
Click here for additional SMTPAppender properties and information.
Append a new reference after the existing references:
<appender-ref ref="Email_Alerts"/> |