logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: log4j, log-levels and glassfish?
Date Sat, 12 Apr 2008 22:39:07 GMT
On Apr 11, 2008, at 3:36 AM, Kristian Rink wrote:

>
> Folks;
>
> maybe a question inappropriate for this list (sorry in advance),
> however I am unsure how to get this solved. Situation is as follows:
> Using log4j in some of our applications which now have to be run  
> inside
> a glassfish application server. So far I managed to make the log-files
> appear in and also be readable in the glassfish management console
> (good), however, I figured out that not all log entries are viewable
> (bad).
>
> Looking closely, it seems that glassfish solely relies upon JDK  
> Logging
> priorities (INFO, FINER, FINEST, ...), so I don't see my log4j DEBUG
> messages in that list. Question, so: Is there a way tweaking log4j to
> use, say, "FINE" or "FINER" instead of DEBUG just for the sake of
> making messages visible there? It's not really a technical but  
> rather a
> "cosmetic" aspect I guess, but I'm not sure how to get out of this...
>
> Thanks in advance for any hints; best regards.
> Kristian
>

The suggestions to use slf4j-over-jul would require you to recompile  
the log4j using apps to use a different log4j-like API that is then  
implemented on top of JDK 1.4 logging.   If you really wanted to force  
stuff through JDK 1.4 logging, another alternative would be to use the  
experimental jul-to-log4j-bridge companion (svn co https://svn.apache.org/repos/asf/logging/sandbox/jul-to-log4j-bridge)

  which can forward log4j logging requests to JDK 1.4 logging and vis- 
versa.  That would not require you to recompile your apps.

However both seem like overkill since your message indicates that you  
only want to change the text output when the layout renders a level.   
You did not express any need to change the logging framework.  As I  
read your message as long as the files say "FINER" or similar, you'd  
be happy regardless of what logging framework was used to generate them.

There are a couple of ways to get there.  You do not mention how the  
log4j using apps are configured or what layout they are currently  
using.  If you can't change the configuration, but could switch out a  
custom log4j.jar, you could change the implementation of  
BasicPatternConverter in src/main/java/org/apache/log4j/helpers/ 
PatternParser.java and recompile log4j.  If you can change the  
configuration, then the cleanest way would be to implement your own  
custom layout that either encapsulates or extends  
org.apache.log4j.PatternLayout and then change your configuration to  
use the new layout.

If you encapsulate, your format(LoggingEvent) method would delegate to  
PatternLayout.format() and then post-process the output to use the  
level labels that you want to use.

If you extend, you'd override PatternLayout.createPatternParser() to  
return an extension of org.apache.log4j.helpers.PatternParser() that  
overrides PatternParser.finalizeConverter(char) where you call  
addConverter(new MyNewLevelConverter()) if the character is 'p' and  
super.finalizeConverter for all other values of c. 
  

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


Mime
View raw message