[logback-user] Custom filter - ClassNotFoundException

Florian Neumeyer flone at gmx.de
Fri Jun 18 15:33:02 CEST 2010


I'm trying to set up a simple configuration with different log files
used depending on the logger name. 
Not wanting to use Joran, because this is a quite frequently accessed
log, I tried to set up a custom logback filter for my Maven2/jetty7/JDK
1.6/logback-0.9.21 project.

I added

<filter class="de.mycorp.LoggerNameFilter" />

to my logback.xml, whereas de.mycorp is the package where all my other
classes reside.



public class LoggerNameFilter extends Filter<ILoggingEvent> {

    public FilterReply decide(ILoggingEvent event) {
        if (event.getLoggerName().equals("chat-message")) {
            return FilterReply.ACCEPT;
        } else {
            return FilterReply.DENY;

Unfortunately Maven throws an error:

-ERROR in ch.qos.logback.core.joran.action.NestedComplexPropertyIA -
Could not create component [filter] of type [de.mycorp.LoggerNameFilter]
java.lang.ClassNotFoundException: de.mycorp.LoggerNameFilter
	at java.lang.ClassNotFoundException: de.mycorp.LoggerNameFilter
	at 	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at 	at java.security.AccessController.doPrivileged(Native Method)
	at 	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at 	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at 	at
	at 	at
	at 	at
	at 	at
	at 	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at 	at ch.qos.logback.core.util.Loader.loadClass(Loader.java:110)

Maybe there's even a better approach to this?

Thanks a lot!

Kind regards,
Florian Neumeyer

More information about the Logback-user mailing list