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 mo...@Storebrand.no on 2001/10/16 19:27:51 UTC

About PropertyConfiguration

Hi

I have been using log4j for 2 days now, and I dare to make a comment:), but
first some background:

I had to make a subclass of Category, in order to log my exceptions my way.
Then I made an ExceptionCategoryFactory. At first this seemed to work
(maybe because I was using rootCategory??), but suddenly I got
"ClassCastException". It was impossible to debug, because the error was
probably caused before runtime? (that is, in the static blocks, class
initialization) However, I suspected it had to do with log4j. I tried a
lot, and read the "short introduction" over and over again:) Then, at last,
I got the bright idea to check the javadoc for PropertyConfigurator:

Class Factories
In case you are using your own subtypes of the Category class and wish to
use configuration files, then you must set the categoryFactory for the
subtype that you are using.

The syntax is:
log4j.categoryFactory=fully.qualified.name.of.categoryFactory.class

Even though it had worked (hadn't it?) before, I was pretty sure that
*this* was my problem. I first tried to write my Factory with a .class
extension, but that was obviously wrong (why add that .class in the
javadoc?) At last it worked!

Some comments/questions:
1) I doesn't seem to logical to have "log4j.categoryFactory" as a key, when
(if) you have multiple factories. Will it work? Wouldn't it be more
intuitive to have "log4j.<category>.factory" as the key?
2) Why did I get a ClassCastException, and not an error message telling me
that I was missing a key-value pair in the propertyfile?
3) Why do we need to add this property at all? Does it have to be this way?

I also spend some time before I got the clue about how to override
additivity. My intuition said something like this:

log4j.category.<mycat>.additivity=false

correct answer is:

log4j.additivity.<mycat>=false.

However, the correct answer is only (I think!) to be found in the example
in the PropertyConfigurator-javadoc.

BUT!! Log4j works wonderfully AND I'm very pleased with it. Thank you to
all of you that has worked with it! My comments are probably not very well
formed, and the best way to view them, is from at newbie's perspective.

Any comments are appreciated.

mvh
Morten Simonsen


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


Re: About PropertyConfiguration

Posted by Don Taylor <do...@yahoo.com>.
Why did you think it was necessary to make a subclass of Category? I
don't understand what you mean by you need to log your exceptions your
way. How were your needs not being met?

-- Don

--- morten.simonsen@Storebrand.no wrote:
> 
> Hi
> 
> I have been using log4j for 2 days now, and I dare to make a
> comment:), but
> first some background:
> 
> I had to make a subclass of Category, in order to log my exceptions
> my way.
> Then I made an ExceptionCategoryFactory. At first this seemed to work
> (maybe because I was using rootCategory??), but suddenly I got
> "ClassCastException". It was impossible to debug, because the error
> was
> probably caused before runtime? (that is, in the static blocks, class
> initialization) However, I suspected it had to do with log4j. I tried
> a
> lot, and read the "short introduction" over and over again:) Then, at
> last,
> I got the bright idea to check the javadoc for PropertyConfigurator:
> 
> Class Factories
> In case you are using your own subtypes of the Category class and
> wish to
> use configuration files, then you must set the categoryFactory for
> the
> subtype that you are using.
> 
> The syntax is:
> log4j.categoryFactory=fully.qualified.name.of.categoryFactory.class
> 
> Even though it had worked (hadn't it?) before, I was pretty sure that
> *this* was my problem. I first tried to write my Factory with a
> .class
> extension, but that was obviously wrong (why add that .class in the
> javadoc?) At last it worked!
> 
> Some comments/questions:
> 1) I doesn't seem to logical to have "log4j.categoryFactory" as a
> key, when
> (if) you have multiple factories. Will it work? Wouldn't it be more
> intuitive to have "log4j.<category>.factory" as the key?
> 2) Why did I get a ClassCastException, and not an error message
> telling me
> that I was missing a key-value pair in the propertyfile?
> 3) Why do we need to add this property at all? Does it have to be
> this way?
> 
> I also spend some time before I got the clue about how to override
> additivity. My intuition said something like this:
> 
> log4j.category.<mycat>.additivity=false
> 
> correct answer is:
> 
> log4j.additivity.<mycat>=false.
> 
> However, the correct answer is only (I think!) to be found in the
> example
> in the PropertyConfigurator-javadoc.
> 
> BUT!! Log4j works wonderfully AND I'm very pleased with it. Thank you
> to
> all of you that has worked with it! My comments are probably not very
> well
> formed, and the best way to view them, is from at newbie's
> perspective.
> 
> Any comments are appreciated.
> 
> mvh
> Morten Simonsen
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

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