Re: Java Logging

[email protected]
Newsgroups gmane.org.user-groups.trijug.juglist
Message-ID <[email protected]>
cebmailbox-trijug-/[email protected] wrote:
> Hmm, care to elaborate?

nah, rather have someone else elaborate for me :-)

http://www.javalobby.org/java/forums/t53843.html

>    
>   Actually let me dump a thought to get your opinion.
>    
>   The most I can see in the way of native support (just trying to use only what is in the JDK) is:
>    
>   Instead of just doing:
>     logger.info((String format(fmt, o1, o2));
>    
>   make my own LogRecord and send that.  Code digging reveals that formatting will be deferred then:
>    
>   if (logger.level < INFO) {
>     LogRecord lr = new LogRecord(INFO, fmt);
>     lr.setParameters(new Object[]{o1, o2});
>     logger.log(lr);
>   }
>    
>   It just seems a bit much!  But is this essentially what it would take?  Really just wondering if there was some built in way to get a one liner.  We have many thousand log points.
>    

So in JDK 5 you can have methods that take an indeterminant number of 
arguments.  This way you can do basically waht you say only the if 
happens before the object creation but inside of the method call.

-Andy

>   -Chris
>   
> 
> [email protected] wrote:
>   Yes. If you're on JDK5 you can use some new features...if not...you're 
> stuck.
> 
> cebmailbox-trijug-/[email protected] wrote:
> 
>>So what's the deal.
>>Every where you read, Java Logging is cheap with formatting done only if the level is appropriate etc.
>>
>>But if I do this:
>>
>>logger.info(String.format("Hello %s\n", name));
>>
>>Isn't the formatting done up front?
>>
>>How can I defer the formatting until the level is checked without checking the level myself everytime?
>>
>>Anyone have any ideas?
>>
>>
>>-Chris
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Juglist mailing list
>>[email protected]
>>http://trijug.org/mailman/listinfo/juglist_trijug.org
> 
> 
> 
> 
> _______________________________________________
> Juglist mailing list
> [email protected]
> http://trijug.org/mailman/listinfo/juglist_trijug.org
>   
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.