You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Mi...@ubs.com on 2004/08/31 18:22:05 UTC
dynamic routing based on level
Hi There,
I am trying to use Log4j to figure out a way to dynamiclly use a different appender depending on the severity level. For example, if the level of the message being logged is below ERROR I would just log it to a file. But if the level is or above ERROR I want to be able to log it to, say, a database (or send a jms message). What would be the strategy to handle this?
I guess one way is to extend the Logger class and override those log metheds (error, fatal, etc). But I'd prefer to use delegation to handle it. In other words, if I could wrapper around the Logger class, and the client will make call through the wrapper. And the wrapper would internally enhance those methods (error, fatal, etc) and then delegate to the Logger. But not sure if that approach would work as I think this would require a separate instance of the wrapper in pair with each instance of the Logger during runtime.
I wonder if anybody has done something to that effect? Any help appreciated.
Mike
Visit our website at http://www.ubs.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
Re: dynamic routing based on level
Posted by Jim Moore <mo...@gmail.com>.
Check the FAQ: http://logging.apache.org/log4j/docs/faq.html#2.9
On Tue, 31 Aug 2004 12:22:05 -0400, mike.yu@ubs.com <mi...@ubs.com> wrote:
> Hi There,
>
> I am trying to use Log4j to figure out a way to dynamiclly use a different appender depending on the severity level. For example, if the level of the message being logged is below ERROR I would just log it to a file. But if the level is or above ERROR I want to be able to log it to, say, a database (or send a jms message). What would be the strategy to handle this?
>
> I guess one way is to extend the Logger class and override those log metheds (error, fatal, etc). But I'd prefer to use delegation to handle it. In other words, if I could wrapper around the Logger class, and the client will make call through the wrapper. And the wrapper would internally enhance those methods (error, fatal, etc) and then delegate to the Logger. But not sure if that approach would work as I think this would require a separate instance of the wrapper in pair with each instance of the Logger during runtime.
>
> I wonder if anybody has done something to that effect? Any help appreciated.
>
> Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org