logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Assum <e...@assum.net>
Subject Removing appenders from a Logger
Date Wed, 10 Oct 2001 08:04:37 GMT

Hi!

First of all, thanks for a great package!

Then; 
While using jakarta-log4j-1.2alpha1 the following occurs:


Given this program:

import org.apache.log4j.*;
import java.util.*;

public class logTest {

    public static void printAppenders(Logger l) {
	System.out.println("Printing appenders for " + l.getName());
	Enumeration e = l.getAllAppenders();
	while (e.hasMoreElements()) {
	    System.out.println(e.nextElement());
	}
	System.out.println("Done");
    }
	
    public static void main (String [] args) {
	int i  = 0, j = 10;
	ConsoleAppender ca =
	    new ConsoleAppender(new PatternLayout("[ %p ] - %c %m%n"));

	BasicConfigurator.configure(ca);

	Logger foo = Logger.getLogger("foo.bar");
	Logger eas = Logger.getLogger("eas.foo");
	eas.removeAllAppenders();

	printAppenders(eas);
	printAppenders(foo);
	
	while (true) {
	    foo.info(i++ + "");
	    eas.info(j-- + "");
	    if (i == 10)
		System.exit(0);
	}
    }

}

I get the following output:
/usr/local/java/bin/java  logTest

Printing appenders for eas.foo
Done
Printing appenders for foo.bar
Done
[ INFO ] - foo.bar 0
[ INFO ] - eas.foo 10
[ INFO ] - foo.bar 1
[ INFO ] - eas.foo 9
[ INFO ] - foo.bar 2
[ INFO ] - eas.foo 8
[ INFO ] - foo.bar 3
[ INFO ] - eas.foo 7
[ INFO ] - foo.bar 4
[ INFO ] - eas.foo 6
[ INFO ] - foo.bar 5
[ INFO ] - eas.foo 5
[ INFO ] - foo.bar 6
[ INFO ] - eas.foo 4
[ INFO ] - foo.bar 7
[ INFO ] - eas.foo 3
[ INFO ] - foo.bar 8
[ INFO ] - eas.foo 2
[ INFO ] - foo.bar 9
[ INFO ] - eas.foo 1

First I would have expected to see a list that my ConsoleAppender
appeared as an appender for appender foo.bar, then I would have
expected that since I removed all appenders from eas I would get no
output from this Logger...



Erik.
-- 
The mail transport agent is not liable for any coffee stains in this message


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message