logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Owens <rookbl...@gmail.com>
Subject Custom Filter Help
Date Sun, 13 Nov 2005 18:07:13 GMT
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

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.


>>> contents of foofilter.h >>>

#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

FilterDecision decide(const LoggingEventPtr& event) const;



>>> 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

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"/>

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


View raw message