At 16:42 15.02.2001 +0100, you wrote:
>Hello,
>
>I suppose I'm not the only one's trying to define custom priorities (TRACE,
>ALWAYS, DEBUG2). It seems this is not as easy as I hoped it would be.
>
>I've started with writing MyPriority (extending Priority as the javadoc says
>you shoulds when enlarging the priority set). That already gave some
>problems because the _INT fields have package scope. This seems like a
>design flaw to me, since I'd like to access these fields in MyPriority (in
>com.mycompany.util.logging package), but I managed to bypass via copy/paste
>(or so I hope).
Good point, I have made the XYZ_INT fields in Priority.java public as they are final
anyway.
>Now the next thing I do is writing MyCategory (extends Category) since I
>need to add the methods trace(), always() and debug2(). I suppose I must
>also implement getInstance() because otherwise I won't be able to create
>MyCategory events. And then I have to write a MyHierarchy class since
>getInstance() requires a hierarchy and who knows what other classes I'll
>have to subclass and I won't even be sure that it will work so...
No, it is easier than you think. First, I suggest that you check out the latest
version of log4j as it is cleaner in many respects. I believe to be production ready
as well.
Once you have the CVS version, see the examples in
...org/apache/log4j/xml/exaples/XCategory.java and other files in the same directory.
By the way, you do not need to sub-class Hierarchy class. There is also documentation
by Paul Glezen explaining how to extend log4j. Cheers, Ceki
----
Ceki Gülcü e-mail: [EMAIL PROTECTED] (preferred)
av. de Rumine 5 [EMAIL PROTECTED]
CH-1005 Lausanne
Switzerland Tel: ++41 21 351 23 15
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]