You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Jeff Epstein <je...@insight-interactive.com> on 2002/04/08 20:50:56 UTC

NEWBIE PROBLEM: Another inheritence question

(This is unrelated to my previous post)

I've declared a "root appender" in the property configuration file.  I
specifically assigned the appender to com.foo.Bar, and did not apply *any*
property configuration variables for com.foo.  However, com.foo is ALSO
printing out to the com.foo.Bar file.  I thought that com.foo.Bar inherits
from com.foo, but not the other way around.

Why is this happening?  I expected there to either be an error (com.foo
doesn't have an appender), or for com.foo simply to not log anything,
anywhere.

Thanks!  (Again)

------------------------------------------------------------
PROPERTY FILE:  log4j_config2.txt
------------------------------------------------------------
# Root logger
	log4j.debug=true
	log4j.rootLogger=INFO, com.foo.Bar

# com.foo.Bar
	log4j.appender.com.foo.Bar=org.apache.log4j.FileAppender
	log4j.appender.com.foo.Bar.file=com_foo_Bar.log
	log4j.appender.com.foo.Bar.append=false
	log4j.appender.com.foo.Bar.layout=org.apache.log4j.PatternLayout
	log4j.appender.com.foo.Bar.layout.ConversionPattern=%-4r %-5p %c{2}
%M.%L %x - %m\n
------------------------------------------------------------


...and here's the Java file (PropertyFile2):
------------------------------------------------------------
	import org.apache.log4j.PropertyConfigurator;
	import org.apache.log4j.Logger;
public class PropertyFile2  {
	public static void main(String[] as_cmdLineParams)  {
		PropertyConfigurator.configure("log4j_config2.txt");

		Logger  lgr = Logger.getLogger("com.foo");
		lgr.debug("lgr debug");
		lgr.info("lgr info");
		lgr.warn("lgr warn");
		lgr.error("lgr error");
		lgr.fatal("lgr fatal");

		Logger barlgr = Logger.getLogger("com.foo.Bar");
		barlgr.debug("barlgr debug");
		barlgr.info("barlgr info");
		barlgr.warn("barlgr warn");
		barlgr.error("barlgr error");
		barlgr.fatal("barlgr fatal");
	}

}
------------------------------------------------------------


Jeff Epstein
Internet Developer
Insight Interactive Group
302  777 0970
jepstein@insight-interactive.com


DISCLAIMER: The information in this message is confidential and may be
legally privileged. It is intended solely for the addressee.  Access to this
message by anyone else is unauthorized.  If you are not the intended
recipient, any disclosure, copying, or distribution of the message, or any
action or omission taken by you in reliance on it, is prohibited and may be
unlawful.  Please immediately contact the sender if you have received this
message in error. Thank you.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>