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 "Sanjay Gupta (sanjaygu)" <sa...@cisco.com> on 2003/07/16 19:07:10 UTC
Does 1.2.x support adding new conversion character to Pattern Layout ?
Hi,
I am trying to add few conversion characters to pattern layout. I know
it was possible in 1.1.x versions by extending PatternLayout and
Category class. Can anyone help how to do it in log4j-1.2.8 considering
extending Logger class is not recommended. I don't want to extend an
appender as all other appenders will become unusable for my new
conversion characters.
Can someone help me please?
Regards,
-Sanjay
-----Original Message-----
From: Ceki Gülcü [mailto:ceki@qos.ch]
Sent: Monday, July 14, 2003 1:44 PM
To: Log4J Users List
Subject: Re: A possible BUG? Logger vs category tag in xml
(DOMConfigurator)
This subject has been discussed many times in the past. Please refer to
the archives.
No, it is not a bug. Subclassing logger class is discouraged.
Consequently, the logger tag does not allow for a class attribute.
However, you can get around this by various means which I am not going
to disclose here as the means are deprecated, discouraged or both.
I recommend wrapping instead of sub-classing.
At 12:21 PM 7/14/2003 -0700, Sanjay Gupta (sanjaygu) wrote:
>Hi,
>
>I am trying to subclass Logger(Category) & LoggerFactory and use
>DOMConfigurator(log4j.xml). I ran into interesting problem. My stuff
>works fine when I configure the logger from program i.e. not using a
>xml or properties file. But when I use xml file, it turns out that
><logger> tag does not have a way of specifying class so My subclassed
>Logger never gets instanciated. I digged deeper and figured out that
><category> tag has "class" attribute.
>So, now I am confused. Should I subclass Logger or Category. If I
should
>subclass Logger then how can I make sure that my subclassed Logger gets
>instanciated from the log4j.xml and not org.apache.log4j.Logger?
>
>I think that it might be a bug?
>
>Regards,
>-Sanjay
--
Ceki For log4j documentation consider "The complete log4j manual"
ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org
Re: Does 1.2.x support adding new conversion character to Pattern Layout ?
Posted by Jonathan Whitall <fi...@yahoo.com>.
Hi Sanjay,
All you have to do is extend PatternLayout and
PatternParser, and then change the references to your
various layouts to use the new code instead of
org.apache.log4j.PatternLayout.
There is actually an example of how to do this
provided in the examples/ directory in the source code
version (it may be in the binary distribution too...
not sure). Anders Kristensen wrote it, and I based my
code from that. It works great, and I have had no
problems with it.
Jonathan
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org