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:21:49 UTC

NEWBIE PROBLEM: Inheritence in property config file

I am an experienced Java programmer, but am new to log4j.  I'm confused as
to why I'm getting this error (error output and code below).

I understand that naming conventions for "inheritence" of loggers should be
the same as your class heirarchy.  Hence:  com.foo and com.foo.Bar.  But I'm
getting an error saying ":WARN No such property [bar] in
org.apache.log4j.ConsoleAppender."

I don't see anything relating to this in the documentation.  I don't see ANY
(complete) listing of all configuration variables avaliable to
PropertyConfigurator's Pmroperty file.

(My goal is to have com.foo.Bar inherit everything from com.foo, *except* I
want it to output only to file, instead of System.out.  I'm pretty sure that
"log4j.additivity.com.foo.Bar=false" is how to do this, but I can't get
beyond this error to confirm.  Does additivity also prevent the formatting
and LEVEL settings from being inherited?)

--------------------------------------------------------
THE OUTPUT
--------------------------------------------------------
[c:\files\a_sandbox\iig\java\development\test\log4j]java
PropertyFileBARERROR
log4j: Parsing for [root] with value=[INFO, com.foo.Bar, com.foo].
log4j: Level token is [INFO].
log4j: Category root set to INFO
log4j: Parsing appender named "com.foo.Bar".
log4j: Parsing layout options for "com.foo.Bar".
log4j: End of parsing for "com.foo.Bar".
log4j: Setting property [file] to [com_foo_Bar.log].
log4j: setFile called: com_foo_Bar.log, true
log4j: setFile ended
log4j: Parsed "com.foo.Bar" options.
log4j: Parsing appender named "com.foo".
log4j: Parsing layout options for "com.foo".
log4j: End of parsing for "com.foo".
log4j:WARN No such property [bar] in org.apache.log4j.ConsoleAppender.
log4j: Parsed "com.foo" options.
log4j: Finished configuring.
lgr info
lgr warn
lgr error
lgr fatal
barlgr info
barlgr warn
barlgr error
barlgr fatal

--------------------------------------------------------
PROPERTY FILE:  log4j_configBARERROR.txt
--------------------------------------------------------

# Root logger
	log4j.debug=true
	log4j.rootLogger=INFO, com.foo.Bar, com.foo

# com.foo
	log4j.appender.com.foo=org.apache.log4j.ConsoleAppender
	log4j.appender.com.foo.layout=org.apache.log4j.PatternLayout

# 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.layout=org.apache.log4j.PatternLayout

--------------------------------------------------------
JAVA CODE:  PropertyFileBARERROR.java
--------------------------------------------------------
	import org.apache.log4j.PropertyConfigurator;
	import org.apache.log4j.Logger;

public class PropertyFileBARERROR  {
	public static void main(String[] as_cmdLineParams)  {
		PropertyConfigurator.configure("log4j_configBARERROR.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");
	}
}

--------------------------------------------------------
--------------------------------------------------------
--------------------------------------------------------

Thank you!


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>