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 Ognjen Kavazovic <ok...@slb.com> on 2004/04/20 17:57:21 UTC

how to propose and submit new features?

Hello,

I would like to propose and contribute a couple of relatively minor features
to the current code base, but am not finding any documentation as to how I
should go about getting the features approved and then submitting the patch.
Could someone point me to the right doc or let me know what I should do in
order to have the following included in the soonest release possible:

1. Being able to specify a wrapper-class for the log4JLogger Logger. For
example, in the Avalon framework there is a Log4JLogger class which wraps a
real log4j logger, and all calls are delegated via the Avalon logger. This
makes the conversion characters %C, %F, %L, %l, and %M useless as they
always resolve to the same class and line number, i.e. the Avalon
Log4JLogger wrapper-class is always the caller. It's a trivial fix to allow
the user to specify the wrapper-class in the properties file and
programatically, in order to identify the existence of such a wrapper class.
It is possible to work-around this by using a custom Logger and overiding
the forcedLog method, but it seems that this is general enough to be
included in the main code base.

2. Being able to specify ConversionPattern PER logging Level. The docs make
it very clear that some conversion chars (esp. the ones listed above) are
very expensive and should be avoided. However, some of them can also be very
useful while debugging, so it would make very good sense to be able to
specify one detailed ConversionPattern for the DEBUG logging Level, and one
generic, less-expensive pattern for the normal INFO logging, for example.


Cheers,
-Ogi.

-----Original Message-----
From: ceki@apache.org [mailto:ceki@apache.org]
Sent: Tuesday, April 20, 2004 5:04 AM
To: logging-log4j-cvs@apache.org
Subject: cvs commit:
logging-log4j/tests/src/java/org/apache/log4j/scheduler - New directory


ceki        2004/04/20 03:03:58

  logging-log4j/tests/src/java/org/apache/log4j/scheduler - New directory

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


RE: patterns and levels

Posted by Ognjen Kavazovic <ok...@slb.com>.
>You could pass a parameter to the extended localisation parameter. You
>can for example write:

>log4j.appender.stdoutAppender.layout.ConversionPattern=[%c] - \
>(%Fx{DEBUG}:%Lx{DEBUG}) %p [%t]: %m%n

>I hope you find the above convincing.

Yes, this is convincing. Didn't know you can pass parameters...good enough
for me. :)

>By the way, the original problem of extracting localisation
>information for DEBUG, but not INFO, for performance reasons, does
>not seem to be worth the effort. Usually, one has 10 times more DEBUG
>statements than INFO and higher.

Right, you are going be slow at DEBUG level whether you have localization
parameters in your pattern or not, due to the sheer volume of DEBUG
messages. However, one wants to be as efficient as possible when logging in
"production mode", presumably at INFO level.

Thanks again.

>Cheers,
>-Ogi.

--
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: patterns and levels

Posted by Ceki Gülcü <ce...@qos.ch>.
At 08:55 PM 4/20/2004, Ognjen Kavazovic wrote:
>Hi Ceki,
>
>thanks for your response. My comments:
>
>1. callerFQCN: what you said makes sense. My work around was due to the fact
>that the wrapper class wasn't mine, but an Avalon Project's Log4JLogger. So
>the bug is really an Avalon bug...I'll submit it to them. thanks!

Yes, submitting a bug report to Avalon is the best thing to do.

>2. Level/PatternConverter: I don't really agree with coupling pattern
>converters and logging levels. These two things are orthogonal, and should
>remain so even with custom PatternConverters. Going back to my example, I
>might want the full details at DEBUG Level. Your proposal would suggest that
>I define a %lineDebug conversion word that displays the line number only
>when in DEBUG mode. But then I might decide that I want full detail at INFO
>Level as well just for a little while until I figure out what's going on.
>Would I need to define yet another conversion word called %lineINFO in order
>to do this? I shouldn't have to define a pattern converter for each
>(conversion word x logging level) combination...
>
>So with the "orthogonal" approach, a properties file might look like this:
>
>log4j.appender.stdoutAppender.layout.ConversionPattern=[%c] - %p [%t]: %m%n
>log4j.appender.stdoutAppender.layout.ConversionPattern.DEBUG=[%c] - (%F:%L)
>%p [%t]: %m%n

You could pass a parameter to the extended localisation parameter. You
can for example write:

log4j.appender.stdoutAppender.layout.ConversionPattern=[%c] - \
(%Fx{DEBUG}:%Lx{DEBUG}) %p [%t]: %m%n

I hope you find the above convincing.

By the way, the original problem of extracting localisation
information for DEBUG, but not INFO, for performance reasons, does
not seem to be worth the effort. Usually, one has 10 times more DEBUG
statements than INFO and higher.


>Cheers,
>-Ogi.

-- 
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp  



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


patterns and levels

Posted by Ognjen Kavazovic <ok...@slb.com>.
Hi Ceki,

thanks for your response. My comments:

1. callerFQCN: what you said makes sense. My work around was due to the fact
that the wrapper class wasn't mine, but an Avalon Project's Log4JLogger. So
the bug is really an Avalon bug...I'll submit it to them. thanks!

2. Level/PatternConverter: I don't really agree with coupling pattern
converters and logging levels. These two things are orthogonal, and should
remain so even with custom PatternConverters. Going back to my example, I
might want the full details at DEBUG Level. Your proposal would suggest that
I define a %lineDebug conversion word that displays the line number only
when in DEBUG mode. But then I might decide that I want full detail at INFO
Level as well just for a little while until I figure out what's going on.
Would I need to define yet another conversion word called %lineINFO in order
to do this? I shouldn't have to define a pattern converter for each
(conversion word x logging level) combination...

So with the "orthogonal" approach, a properties file might look like this:

log4j.appender.stdoutAppender.layout.ConversionPattern=[%c] - %p [%t]: %m%n
log4j.appender.stdoutAppender.layout.ConversionPattern.DEBUG=[%c] - (%F:%L)
%p [%t]: %m%n

In this example, there's a general conversion patter applicable to all
levels, with an override for DEBUG mode. If I then changed my mind and
wanted the same logging details for INFO Level and higher, I would just
change DEBUG to INFO in the second line.

Thoughts?

Cheers,
-Ogi.

-----Original Message-----
From: Ceki Gülcü [mailto:ceki@qos.ch]
Sent: Tuesday, April 20, 2004 11:31 AM
To: Log4J Developers List
Subject: Re: how to propose and submit new features?



Hello Ognjen,

Please see my comments below.

At 05:57 PM 4/20/2004, Ognjen Kavazovic wrote:
>Hello,
>
>I would like to propose and contribute a couple of relatively minor
features
>to the current code base, but am not finding any documentation as to how I
>should go about getting the features approved and then submitting the
patch.
>Could someone point me to the right doc or let me know what I should do in
>order to have the following included in the soonest release possible:

Contacting this list and explaining what you have in mind was the right
thing to do.

>1. Being able to specify a wrapper-class for the log4JLogger Logger. For
>example, in the Avalon framework there is a Log4JLogger class which wraps a
>real log4j logger, and all calls are delegated via the Avalon logger. This
>makes the conversion characters %C, %F, %L, %l, and %M useless as they
>always resolve to the same class and line number, i.e. the Avalon
>Log4JLogger wrapper-class is always the caller. It's a trivial fix to allow
>the user to specify the wrapper-class in the properties file and
>programatically, in order to identify the existence of such a wrapper
class.
>It is possible to work-around this by using a custom Logger and overiding
>the forcedLog method, but it seems that this is general enough to be
>included in the main code base.

Your wrapper should use the generic Logger.log() method.

The signatures is

log(String callerFQCN, Priority level, Object message, Throwable t)

where callerFQCN is the fully qualified name of the calling class.

There is really no need to override forceLog method.

>2. Being able to specify ConversionPattern PER logging Level. The docs make
>it very clear that some conversion chars (esp. the ones listed above) are
>very expensive and should be avoided. However, some of them can also be
very
>useful while debugging, so it would make very good sense to be able to
>specify one detailed ConversionPattern for the DEBUG logging Level, and one
>generic, less-expensive pattern for the normal INFO logging, for example.

In log4j version 1.3, it will be very easy to add your own pattern
converters. See https://www.qos.ch/logging/PatternLayout.html for more
details.

Thus, you could create your own pattern converters, say $Cx, %Fx, $Lx,
and %Mx, that extract location information only if the level is higher
than debug.

I hope this makes sense. If it does not, please shout.

>Cheers,
>-Ogi.
>
>-----Original Message-----
>From: ceki@apache.org [mailto:ceki@apache.org]
>Sent: Tuesday, April 20, 2004 5:04 AM
>To: logging-log4j-cvs@apache.org
>Subject: cvs commit:
>logging-log4j/tests/src/java/org/apache/log4j/scheduler - New directory
>
>
>ceki        2004/04/20 03:03:58
>
>   logging-log4j/tests/src/java/org/apache/log4j/scheduler - New directory
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-dev-help@logging.apache.org

--
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: how to propose and submit new features?

Posted by Ceki Gülcü <ce...@qos.ch>.
Hello Ognjen,

Please see my comments below.

At 05:57 PM 4/20/2004, Ognjen Kavazovic wrote:
>Hello,
>
>I would like to propose and contribute a couple of relatively minor features
>to the current code base, but am not finding any documentation as to how I
>should go about getting the features approved and then submitting the patch.
>Could someone point me to the right doc or let me know what I should do in
>order to have the following included in the soonest release possible:

Contacting this list and explaining what you have in mind was the right 
thing to do.

>1. Being able to specify a wrapper-class for the log4JLogger Logger. For
>example, in the Avalon framework there is a Log4JLogger class which wraps a
>real log4j logger, and all calls are delegated via the Avalon logger. This
>makes the conversion characters %C, %F, %L, %l, and %M useless as they
>always resolve to the same class and line number, i.e. the Avalon
>Log4JLogger wrapper-class is always the caller. It's a trivial fix to allow
>the user to specify the wrapper-class in the properties file and
>programatically, in order to identify the existence of such a wrapper class.
>It is possible to work-around this by using a custom Logger and overiding
>the forcedLog method, but it seems that this is general enough to be
>included in the main code base.

Your wrapper should use the generic Logger.log() method.

The signatures is

log(String callerFQCN, Priority level, Object message, Throwable t)

where callerFQCN is the fully qualified name of the calling class.

There is really no need to override forceLog method.

>2. Being able to specify ConversionPattern PER logging Level. The docs make
>it very clear that some conversion chars (esp. the ones listed above) are
>very expensive and should be avoided. However, some of them can also be very
>useful while debugging, so it would make very good sense to be able to
>specify one detailed ConversionPattern for the DEBUG logging Level, and one
>generic, less-expensive pattern for the normal INFO logging, for example.

In log4j version 1.3, it will be very easy to add your own pattern
converters. See https://www.qos.ch/logging/PatternLayout.html for more
details.

Thus, you could create your own pattern converters, say $Cx, %Fx, $Lx,
and %Mx, that extract location information only if the level is higher
than debug.

I hope this makes sense. If it does not, please shout.

>Cheers,
>-Ogi.
>
>-----Original Message-----
>From: ceki@apache.org [mailto:ceki@apache.org]
>Sent: Tuesday, April 20, 2004 5:04 AM
>To: logging-log4j-cvs@apache.org
>Subject: cvs commit:
>logging-log4j/tests/src/java/org/apache/log4j/scheduler - New directory
>
>
>ceki        2004/04/20 03:03:58
>
>   logging-log4j/tests/src/java/org/apache/log4j/scheduler - New directory
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-dev-help@logging.apache.org

-- 
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp  



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org