Thank you very much for the explanation. It makes perfect sense for me. But in my case I hit slightly different problem. The class foo.bar.XY calls lets say test.bulk.ZY and the class com.create.CR calls test.bulk.ZY as well.
I need two full log files for foo.bar.XY and test.bulk.ZY with all the logs information from test.bulk.ZY. How to do that with two loggers defined for each of the foo.bar.XY and test.bulk.ZY? Bender Heri wrote: > > Now things getting clearer. > Log4j maintains a logger hierarchy which is determined by the dot withing > the logger names, similar to the package hierarchy in java. Example: > Config: you declare a logger "foo.bar" and a root logger, both have one > (the same) appender attached. > Code: class foo.bar.XY instantiates the logger "foo.bar.XY" and issues a > log call to it. > -> Log4j will look for a logger "foo.bar.XY" which is not declared. After > that it climbs up the hierarchy path. Thus it looks for logger "foo.bar" > which is found. The appenders of this logger will be served. Now the > additivity flag comes into play. If it is set to true (the default), log4j > will go on searching the next higher logger in hierarchy "foo". No logger > will be found. At the end it reaches the root logger and serves the > appenders of the root logger. If the additivity flag of "foo.bar" would be > set to false, log4j would stop looking further up for more loggers. > With additivity=true you will end up to have the same log statement twice > in your appender, with additivity=false only the appenders of the logger > "foo.bar" were served. > > Heri > >> -----Original Message----- >> From: Camer38 [mailto:[EMAIL PROTECTED] >> Sent: Thursday, July 03, 2008 6:22 PM >> To: log4j-user@logging.apache.org >> Subject: Re: "additivity" attribute does not work for >> user-defined logger but works for root logger. >> >> >> Thanks for your answer and your time. >> >> Why the root logger defined: >> <root> >> <level value="debug"/> >> <appender-ref ref="taskRedirection"/> >> <appender-ref ref="addQuestionSequenceOrder"/> >> </root> knows that all the logs from ALL the classes should >> go the the file specified by appenders:taskRedirection, >> addQuestionSequenceOrder and a logger: >> >> <logger >> name="curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter" >> additivity="true"> >> <level value="debug"/> >> <appender-ref ref="addQuestionSequenceOrder"/> >> </logger> knows that ONLY logs from that class >> curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter >> has to be "served"? >> >> Is no't realy any way to duplcate the work of the root logger >> in logger specified by the name >> curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter? >> >> If not, why this parameter additivity="true" is present at >> all? It does nothing. >> >> MR. >> >> >> >> Thorbjørn Ravn Andersen wrote: >> > >> > Camer38 skrev den 03-07-2008 15:25: >> >> My assumption was that if I run one of the class >> >> >> curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter I would >> >> got all the logs from that class and all the classes used >> internally >> >> by curam.tools.upgradehelper.ieg.QuestionSequenceOrderConverter in >> >> the addQuestionSequenceOrderTool.log. >> >> >> > No. The logger frameworks do not do magic to deduce where logging >> > should go. If you want for classes called to use a >> specific logger, >> > you must pass it as an argument like all values you want to use. >> > >> > >> >> Instead I got an log4j warning: >> >> >> >> log4j:WARN No appenders could be found for logger >> >> (curam.tools.upgradehelper.util.SQLStatements). >> >> >> >> >> > You are most likely using a logger variable in >> SQLStatements which has >> > been defined at the top of that class referring to >> SQLStatments.class. >> > >> > This does not allow log4j to distinguish between the two >> cases you have. >> > >> > I have the same problem in a project where it is two >> threads logging >> > in the same file. I have not yet found a good solution. >> >> During my testing I have defined a root logger as well, >> but it does >> >> not do what I want. >> >> >> >> All the expected lines are present in both files but the files are >> >> populated with the log from the same class. >> >> <root> >> >> <level value="info"/> >> >> <appender-ref ref="taskRedirection"/> >> >> <appender-ref ref="addQuestionSequenceOrder"/> >> >> </root> >> >> >> >> >> > >> > This say that you want all messages at info level or higher >> to go to >> > both the taskRedirection appender AND the addQuestionSequenceOrder >> > appender. >> > >> > -- >> > Thorbjørn >> > >> > >> --------------------------------------------------------------------- >> > To unsubscribe, e-mail: [EMAIL PROTECTED] >> > For additional commands, e-mail: [EMAIL PROTECTED] >> > >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/%22additivity%22-attribute-does-not-work >> -for-user-defined-logger-but-works-for-root-logger.-tp18259092 > p18263109.html >> Sent from the Log4j - Users mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/%22additivity%22-attribute-does-not-work-for-user-defined-logger-but-works-for-root-logger.-tp18259092p18316555.html Sent from the Log4j - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]