Hi, Now I know what the problem is: An "old" Log4J version 1.1.3 was lying around in the classpath and was used instead of Log4J 1.2.x. With the 1.2 version everything works OK.
The relevant difference between these versions, which caused this strange behaviour, can be found in method PropertySetter.setProperties(Properties properties ,String prefix): The 1.1.x version iterates over the Properties with properties.keys() whereas the 1.2.x version uses properties.propertyNames(). With other words: in 1.1.x the default properties of the properties-object were ignored, which explains my configuration problems. Sorry for wasting your time, Holger ---- Holger Brands eurodata GmbH & Co. KG Großblittersdorfer Straße 257-259 66119 Saarbrücken > > Hi, > > I have some problems configuring Log4J for > my requirements. > Perhaps I am missing something or doing something > wrong. > > I want to configure a Category, which exclusively > uses exactly one specified Appender. > When I am using a property file with the > following entries, it works for me: > > # file DemoEditor.properties > log4j.debug=true > log4j.rootCategory=INFO, Konsole, Datei > > # settings for Konsole and Datei omitted > > # relevant settings > log4j.appender.Proto=org.apache.log4j.RollingFileAppender > log4j.appender.Proto.File=${user.home}/CommandProtokoll.log > log4j.appender.Proto.layout=org.apache.log4j.xml.XMLLayout > > log4j.category.Protokoll=INFO, Proto > log4j.additivity.Protokoll=false > # end > > Category Protokoll only uses Appender Proto, OK. > > The problem arises, when I want to configure the rootCategory > and its appenders via the configuration file as above, but > the options for category Protokoll and the appender Proto > via system properties instead of supplying these > with the property file. > > I am doing the following in my application: > > // setting options via system properties > > System.setProperty("log4j.appender.Proto", > "org.apache.log4j.RollingFileAppender"); > System.setProperty("log4j.appender.Proto.File", > System.getProperty("user.home") + > System.getProperty("line.separator") + > "CommandProtokoll.log"); > System.setProperty("log4j.appender.Proto.layout", > "org.apache.log4j.xml.XMLLayout"); > System.setProperty("log4j.category.Protokoll","INFO, Proto"); > System.setProperty("log4j.additivity.Protokoll","false"); > > Properties props = new Properties(System.getProperties()); > > // load other properties via config file > try { > props.load(new java.io.FileInputStream("DemoEditor.properties")); > } > catch(Exception ex) {}; > > // configure log4j > org.apache.log4j.PropertyConfigurator.configure(props); > > > In this case the relevant debug output of log4j is: > ... > log4j: Parsing for [Protokoll] with value=[INFO, Proto]. > log4j: Priority token is [INFO]. > log4j: Category Protokoll set to INFO > log4j: Parsing appender named "Proto". > log4j:WARN File option not set for appender [Proto]. > log4j:WARN Are you using FileAppender instead of ConsoleAppender? > log4j: Parsing layout options for "Proto". > log4j: End of parsing for "Proto". > log4j: Parsed "Proto" options. > log4j: Handling log4j.additivity.Protokoll=[false] > log4j: Setting additivity for "Protokoll" to false > log4j: Finished configuring. > > Why does log4j behave differently here ? > It seems to ignore at least the File property of appender Proto. > > Am I missing something here or is this some kind of bug ? > At least it looks like an inconsistent behaviour to me. > > > Thanks for your help, > Holger > > > P.S.: > I am using: > log4j 1.2.1 > Win 2000 > JDK 1.3.1-b24 (JDK of JBuilder 6) > > > ---- > Holger Brands > eurodata GmbH & Co. KG > Großblittersdorfer Straße 257-259 > 66119 Saarbrücken > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>