Currently I use log4j via an abstracted static class. I have a method called
warn, which does the following (it is a little aprroximated - don't have the
code in from of me):

public void warn(Class class, String message) {
  Category cat = Category.getInstance(class.getName());
  cat.warn(message);
}

The Category and its appenders are created in the static classes getInstance
method by using a PropertyConfigurator. Now for me to extend this idea to
use system and user warnings, from what your saying I'd do the following:

public void systemWarn(Class class, String message) {
  Category cat = Category.getInstance(class.getName()+".system");
  cat.warn(message);
}



public void userWarn(Class class, String message) {
  Category cat = Category.getInstance(class.getName()+".user");
  cat.warn(message);
}

However, I'm unsure how this would work - surely the getInstance method will
try and find a category for a class (assuming I called userWarn() for a
class in com.bob.MyClass) com.bob.MyClass.user (e.g. a non-existing class).
So when configuring my Category initially using the property file, how would
I create my Category to match this when getInstance is called?

Sorry if my question doesn't make much sense.....

sam
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "LOG4J Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, July 25, 2001 1:31 PM
Subject: Re: Multiple Appenders


>
> How about using two categories
> Category catUser = Category.getInstance(className.class.getName() +
> ".user");
> Category catSystem = Category.getInstance(className.class.getName() +
> ".system");
>
> Then you could set different appenders to the different categories.
> You could log user events like this:
> catUser.info("this is a user message");
> and system events:
> catSystem.info("this is a system event");
>
> my2cents
> Mark Russell
> PNC
> 412-768-9603



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to