Women in Technology

Hear us Roar



Article:
  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)

Full Threads Newest First

Showing messages 1 through 1 of 1.

  • Chris Adamson photo Errors in sample-code for log4j
    2004-10-11 11:57:44  Chris Adamson | O'Reilly AuthorO'Reilly Blogger [View]

    These errors have been corrected in the article. Thank you for your feedback.
    --Chris Adamson, "invalidname", Editor