To the best of my knowledge, it all works fine.
I have just done the same thing and I got it all to work.
However, if I have anything wrong here, some one please speak up.
Hints:
- In your code that uses your new category, import *IT* and
*NOT* the original log4j Category.
- You need to add a couple of lines to the Config file
to have it recognize the new categories and priorities.
For example, I have created a new priority called NOTIFY. It is called
out in my new Category code called MyCategory (a near-clone of XCategory).
Another piece of code that does logging accesses it as:
import com.us.utilities.MyCategory ;
/////// import org.apache.log4j.Category ;
public class SomeClass
{
// get the logging flag for our Category (which is our class name)
//
private static MyCategory log =
(MyCategory) MyCategory.getInstance( SomeClass.class.getName() ) ;
and then uses it as:
log.debug("Here I am on line 10.") ;
My XML configuration file starts with:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" [
<!ENTITY MyCategory "com.us.utilities.MyCategory">
]>
and then later I "define" the new categories . . .
<!-- Define the custom stuff -->
<category name="MyCategory" class="com.us.utilities.MyCategory">
<priority value="NOTIFY"
class="com.us.utilities.MyPriority"/>
</category>
and later I use this new category in an appender as . . .
<!-- Only write events with Priority=NOTIFY to this appender -->
<filter class="org.apache.log4j.varia.PriorityMatchFilter">
<param name="PriorityToMatch" value="NOTIFY" />
<param name="AcceptOnMatch" value="true" />
</filter>
<filter class="org.apache.log4j.varia.DenyAllFilter">
</filter>
----------------------------------------------------
Hope this helps. If this is still not clear, email me directly and I can send
you files.
Jay Riddell
Software Developer
Dorado Software
|--------+----------------------->
| | rossmcormier@|
| | yahoo.com |
| | |
| | 05/29/01 |
| | 10:02 AM |
| | Please |
| | respond to |
| | log4j-user; |
| | Please |
| | respond to |
| | ross.cormier |
| | |
|--------+----------------------->
>----------------------------------------------------------------------------|
| |
| To: [EMAIL PROTECTED] |
| cc: (bcc: Jay Riddell/Enron Communications) |
| Subject: PriorityMatchFilter and XPriority |
>----------------------------------------------------------------------------|
Hi,
I am using my own Category and Priority based on the
XCategory and XPriority classes in log4j/xml/examples.
I am trying to set up a PriorityMatchFilter to filter
on on of my new priorities. Unfortuntaly, this does
not work. I can substitute one of the built-in
Priorities for my custom one, and the filter works
fine.
Is this a bug?
Thanks,
Ross
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.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]