Reporting Application Errors by Email
Subject:   Errors in sample-code for log4j
Date:   2004-09-30 05:55:24
From:   HughG
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:

  1. you have to specify a class for layout-declaration: in this case, you have to add ''class="org.apache.log4j.PatternLayout" '' to the definition
  2. 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)

1 to 1 of 1
1 to 1 of 1