Thanks for the article, I did not know about the handy SMTPAppender before!
However, under log4j 1.2.8, the sample-code won't work, and you have to include the necessary JARs or you will get NoClassDefFound-errors when trying to configure the Logger in log4j:
- you have to specify a class for layout-declaration: in this case, you have to add ''class="org.apache.log4j.PatternLayout" '' to the definition
- the same applies to the filter-definition, where you have to add '' class="org.apache.log4j.varia.LevelRangeFilter" '' to be able to use the Level-filter-settings
additionally, you can specify whether to filter OUT these Levels or ONLY log these Levels by specifying an additional parameter with '' <param name="AcceptOnMatch" value="true"/> ''
As for the missing JARs, these are:
- activation.jar (SMTPAppender creates a DataSource-instance)
- mail.jar (for the message-handling)