logo       

Custom Filter Help: msg#00023

Subject: Custom Filter Help
Hey dudes,

I am trying to implement a custom filter using log4cxx.  I have subclassed Filter and implemented a decide() method.  However, when I try to execute my program, log4cxx complains that my filter class cannot be found.  Am I missing a step?  Do I need to use one of the macros defined in object.h like DECLARE_LOG4CXX_OBJECT()? 

The output of my program is:

log4cxx: Could not instantiate class [FooFilter].
log4cxx: Class not found: FooFilter



Excerpts from my code is below.

I would appreciate any help on this.

Thanks

>>> contents of foofilter.h >>>

#if !defined(AFX_FOOFILTER_H__94B10DBB_D815_4D44_8F8A_423493A9F473__INCLUDED_)
#define AFX_FOOFILTER_H__94B10DBB_D815_4D44_8F8A_423493A9F473__INCLUDED_

#include <log4cxx/spi/filter.h>

using namespace log4cxx;
using namespace log4cxx::spi;

class FooFilter : public spi::Filter 
{
public:

  FooFilter();
  FilterDecision decide(const LoggingEventPtr& event) const;

};

#endif

>>> contents of FooFilter.cpp >>>

#include <iostream>
#include <log4cxx/spi/filter.h>
#include <log4cxx/spi/loggingevent.h>
#include "FooFilter.h"

using namespace log4cxx;
using namespace log4cxx::spi;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

FooFilter::FooFilter(){
  std::cout << "FooFilter: constructing.";
}


Filter::FilterDecision FooFilter::decide(
   const spi::LoggingEventPtr& event) const {

  std::cout << "FooFilter: deciding now.";

  return Filter::ACCEPT;
}

>>> contents of log4j.xml >>>

<?xml version="1.0" encoding="UTF-8" ?>

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
       
  <appender name="apple" class="org.apache.log4j.FileAppender">
    <param name="File" value="logs/apple.log"/>
    <param name="Append" value="false"/>
    <layout class="org.apache.log4j.SimpleLayout"/>
    <filter class="FooFilter"/>
  </appender>

  <root>
    <priority value ="debug"/>
    <appender-ref ref="apple"/>
  </root>

</log4j:configuration>
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe