I am having the same problem.  I want the category hierarchy to follow
object ownership rather than class ancestry.  For example, I want
objects of class A that are contained in container object X to have a
log category of X.A and objects of the same class that are contained in
container Y to have category Y.A.

My solution to this problem was to create a LogFactory which takes two
strings, the name of the parent log, and the name of the new log.  The
factory takes the name of the parent log and tags a "." and the new log
name onto the end.  Of course this is what happens automatically with
class hierarchies when you use class.getName() to name the category, but
since I am not using that hierarchy, I have to do it myself.

So every object that uses logging, must take a string (the name of the
parent log) instead of an actual log, which would be preferrable.  I
know most people use the class hierarchy to separate the log categories,
eliminating the need for an additional constructor parameter, but I have
instances of the same class floating all around the network and I need
to know explicitly which container it is comming from.

I think the better solution would be to include a non-static method in
the Category (or Logger) class that allows you to explicitly create a
child log.  Something like


public Category getChild(String childName);


On Tue, 2002-01-29 at 11:29, Hunter, Bryan wrote:

    Is there a way to explicity set a category's parent using the API?  I don't
    want to explicity put entries in my log4j.properties file for each class I
    create a category for.  This seems way too much work and unmanagable.  I
    want all my categories using the same Appender.
    
    I've wrapped Category in my own class (this will also make it easier to move
    to Log4J ver 1.2 where Category is deprecated).  I'm using Log4J ver 1.1.3.
    
    
    I want to have all my category's inherit appenders from a parent category
    for my project, but I don't want them to inherit directly from the
    rootCategory.  I'm running Jboss and it uses Log4J for its logging
    (resetting the rootCategory will affect Jboss' logging and I don't want to
    change this).  I want to set additive to false for my parent category (not
    inherit appenders from rootCategory), then have all my child categorys have
    additivity.
    
    
    --
    Bryan K. Hunter
    [EMAIL PROTECTED]
    Senior Software Engineer                        "Winning Decisions for you
    and your Customers"
    OmniChoice                                           www.omnichoice.com
    2570 Blvd. Of Generals, Suite 210            610-630-2103 ext.  135
    Norristown, PA  19403                            610-630-2117 (fax)
    www.omnichoicesolutions.com
    
    
    
    --
    To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
    For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
    
    

Eric George
[EMAIL PROTECTED]
hm: 720-855-0484
cell: 720-231-2335

Reply via email to