logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David <achepat...@yahoo.es>
Subject RE: How configure the categories for console, logFile and htmlFile showing different levels
Date Mon, 18 Sep 2006 08:56:36 GMT
Dear Jacob,
   
  Thanks for your comments, I have addes this new features on Bugzilla: 
   
  http://issues.apache.org/bugzilla/show_bug.cgi?id=40532
   
  About your suggestions, I have a general idea about what you mean in order to specify the
oposite situation (so, limit my classes and for others external libraries apply a default
policy: warn level), the problem is that I am not Log4j expert and it works for me right now,
with more configuration effort, :-(
   
  Please could you try to expose those changes on my original log4j.xml file?
   
  Thanks a lot,
   
  David
   
  I am going to add this new feature on Bugzila

Jacob Kjome <hoju@visi.com> wrote:
  At 07:19 PM 9/17/2006, you wrote:
>Dear Bender,
>
>Thanks four your xml sample now it works as I 
>expect, on the attached file you will find it.
>
>Nevertheless I have some comments, I am not 
>log4j expert, but I guess the syntax could be 
>simplified, and probably it is possible:
>
>1. With your suggestion, I have to specify 
>explicit each external library, but the opossite 
>would be easier to define, but I don't know how 
>to set it, all my classes belong to the package: 
>com.schinvest, so this package will be at INFO 
>level for console, file, and htmlFile, any thing 
>else will have WARNING level for all appenders. 
>Probably this could be configurate in simpler 
>way, but I don't know how to do it.
>
>2. On cathegory node there is no way on the 
>class attribute to specify more than one class at the same time, is that true?
>
>
> 
> 
> 
>
>
>so this cathegory will be applied for org.* and 
>net.sf.* packages, that would simplify the log4 
>configuration, but I have tested it and it doesn't work.
>

First, you should be using , not 
. And it's , not 

Otherwise, Interesting idea. It won't work and I 
doubt very much that this will be added to 
Log4j-1.2.xx, but it might be something for later 
versions. You could post an enhancement report in bugzilla.

Your only real chance to get this behavior 
currently is to set everything in the 
logger. In fact, I usually set most everything 
in the logger and only define other 
loggers if I want behavior in any way different 
than what I set in the logger. Also, I 
usually set the logger to value="warn"/> and specify a lower level only when I truly need
it.

Below is how I would envision your config 
file. I think you'll find it 100% more 
manageable. By defaulting to a higher level 
"warn" in , you can then make an exception 
for your own organization's package instead of 
having to exhaustively account for all the 
external packages your application 
uses. Generalize the unknown (external library 
config) and specify the known (your organization's config)....




xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

class="org.apache.log4j.ConsoleAppender">






value="%5p%x[%M](%C{1}:%L) - %m%n"/>











class="org.apache.log4j.DailyRollingFileAppender">









value="[%d{yyyy-MM-dd 
hh:mm:ss},%6.6r]%5p%x[%M](%C{1}:%L) - %m%n"/>











class="org.apache.log4j.DailyRollingFileAppender">


































Jake


>Thanks for your help,
>
>David
>
>Bender Heri wrote:
>Here is an example of an xml configuration which 
>uses filters (BTW: Using this two appenders when 
>debugging in eclipse the console shows the DEBUG 
>and INFO in black color and the others in red 
>color). You can also write your own filter class 
>where you are free to filter what you want. Be 
>careful on the ordering when extending this xml 
>file. The logj4 parser expects first all appenders followed by all loggers.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>Yahoo! Messenger with Voice. 
>Make 
>PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.
>
>
>
>>This configuration defines three appenders:
>console: With warn level
>file: With debug level four all classes except for external libraries of
>          our application.
>htmlFile: With the same configuration as console, except for HTML format.
>-->
>
>>xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
>
> > class="org.apache.log4j.ConsoleAppender">
> 

> 

> 
> 
> value="%5p%x[%M](%C{1}:%L) - %m%n"/>
> 
> 
> 

> 

> 

> 
> 
>
> > class="org.apache.log4j.DailyRollingFileAppender">
> 
> 

> 

> 

> 
> 
> value="[%d{yyyy-MM-dd 
> hh:mm:ss},%6.6r]%5p%x[%M](%C{1}:%L) - %m%n"/>
> 
> 
> 

> 

> 

> 
> 
>
> > class="org.apache.log4j.DailyRollingFileAppender">
> 

> 

> 
> 

> 

> 
> 
> 

> 

> 

> 
> 
>
>
> > main pattern on the name attribute
>     Note: You can't concatenate the class names on one category, for example:
>     putting in the name="org, net.sf" together.-->
> 
> 
> 
> 
> 
>
> 
> 
> 
> 
> 
>
> 
> 
> 
> 
> 
>
> 
> 
> 
> 
> 
>
> 
> 
> 
> 
> 
>
> 
> 
> 
> 
> 
>
> 
> 
> 
> 
> 
> 
>
> 
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org


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



 		
---------------------------------
 All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message