Re: Log Utility

2008-04-07 Thread Maarten Bosteels
Or you can use log4j via SLF4J:

void *debug*(String
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
format,
   Object
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html arg1,
   Object
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html arg2)

Log a message at the DEBUG level according to the specified format and
arguments.

This form avoids superfluous object creation when the logger is disabled for
the DEBUG level.

*Parameters:*format - the format stringarg1 - the first argumentarg2 - the
second argument
http://www.slf4j.org/api/org/slf4j/Logger.html#debug(java.lang.String,%20java.lang.Object,%20java.lang.Object)

Maarten

On Sun, Apr 6, 2008 at 10:46 PM, Jacob Kjome [EMAIL PROTECTED] wrote:


 How about LogMF or LogSF in Log4j's own Extras companion?

 http://logging.apache.org/log4j/companions/extras/index.html


 http://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/LogMF.html

 http://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/LogSF.html


 Jake


 Wim Deblauwe wrote:

  You probably mean that you want to avoid expensive string concatenation
  and
  toString() operations if you logging is not logged anyway. There are a
  number of solutions to avoid that using
  log5jhttp://code.google.com/p/log5j/or
  logback http://logback.qos.ch/.
 
  regards,
 
  Wim
 
  2008/4/4, Tim Nguyen [EMAIL PROTECTED]:
 
   Thank you! It is similar to what I wanted to do. This is more like the
   solution for one class. Is there anyway to check for all classes? I
   have
   hundreds of classes and I want to have an util that I can just replace
   the
   current logging  (e.g: logger.debug(String)) with LogUtil (e.g:
   LogUtil.debug(String) and it does the trick. That way I can just
   replace
   All the logger with LogUtil :)
  
   Thanks again for your help!
  
  
   - Original Message 
   From: Robert Pepersack [EMAIL PROTECTED]
   To: Log4J Users List log4j-user@logging.apache.org
   Sent: Friday, April 4, 2008 12:14:30 PM
   Subject: Re: Log Utility
  
   Hi Tim,
  
   The Logger class has a way of checking the level first.
  
   First put this in your instance variables:
  
  private static final Logger logger =
   Logger.getLogger(my.package.MyClass);
  
  private final boolean debug = logger.isDebugEnabled();
  
   Then put this in your method:
  
  if (this.debug)
  {
  logger.debug(new String(test));
  }
  
   Hope this helps.
  
   Robert Pepersack
   Senior Lead Developer
   Maryland Insurance Administration
   410-468-2054
  
Tim Nguyen [EMAIL PROTECTED] 04/04/2008 3:02 PM 
 
 Hi,
  
   I am writing a Log Utility to check the log level first before
   creating a
   string object. For example, if my log level is INFO, and I call:
  
   log.debug(new String(test));
  
   It will still instantiate the String object even thought it doesn't
   log
   anything.
  
   So I would like to write an Utility to check the level first, if the
   log
   level is lower, then I don't have to instantiate the object and just
   skip
   it.
   Anybody knows what is the easy way to do that?
  
   Thanks,
  
  
  
  
  
  

   
   You rock. That's why Blockbuster's offering you one month of
   Blockbuster
   Total Access, No Cost.
   http://tc.deals.yahoo.com/tc/blockbuster/text5.com
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
  
  
  
  
  

   
   You rock. That's why Blockbuster's offering you one month of
   Blockbuster
   Total Access, No Cost.
   http://tc.deals.yahoo.com/tc/blockbuster/text5.com
  
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Log Utility

2008-04-06 Thread Jacob Kjome


How about LogMF or LogSF in Log4j's own Extras companion?

http://logging.apache.org/log4j/companions/extras/index.html

http://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/LogMF.html
http://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/LogSF.html


Jake

Wim Deblauwe wrote:

You probably mean that you want to avoid expensive string concatenation and
toString() operations if you logging is not logged anyway. There are a
number of solutions to avoid that using
log5jhttp://code.google.com/p/log5j/or
logback http://logback.qos.ch/.

regards,

Wim

2008/4/4, Tim Nguyen [EMAIL PROTECTED]:

Thank you! It is similar to what I wanted to do. This is more like the
solution for one class. Is there anyway to check for all classes? I have
hundreds of classes and I want to have an util that I can just replace the
current logging  (e.g: logger.debug(String)) with LogUtil (e.g:
LogUtil.debug(String) and it does the trick. That way I can just replace
All the logger with LogUtil :)

Thanks again for your help!


- Original Message 
From: Robert Pepersack [EMAIL PROTECTED]
To: Log4J Users List log4j-user@logging.apache.org
Sent: Friday, April 4, 2008 12:14:30 PM
Subject: Re: Log Utility

Hi Tim,

The Logger class has a way of checking the level first.

First put this in your instance variables:

private static final Logger logger =
Logger.getLogger(my.package.MyClass);

private final boolean debug = logger.isDebugEnabled();

Then put this in your method:

if (this.debug)
{
logger.debug(new String(test));
}

Hope this helps.

Robert Pepersack
Senior Lead Developer
Maryland Insurance Administration
410-468-2054


Tim Nguyen [EMAIL PROTECTED] 04/04/2008 3:02 PM 

Hi,

I am writing a Log Utility to check the log level first before creating a
string object. For example, if my log level is INFO, and I call:

log.debug(new String(test));

It will still instantiate the String object even thought it doesn't log
anything.

So I would like to write an Utility to check the level first, if the log
level is lower, then I don't have to instantiate the object and just skip
it.
Anybody knows what is the easy way to do that?

Thanks,





  

You rock. That's why Blockbuster's offering you one month of Blockbuster
Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








  

You rock. That's why Blockbuster's offering you one month of Blockbuster
Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Log Utility

2008-04-05 Thread Wim Deblauwe
You probably mean that you want to avoid expensive string concatenation and
toString() operations if you logging is not logged anyway. There are a
number of solutions to avoid that using
log5jhttp://code.google.com/p/log5j/or
logback http://logback.qos.ch/.

regards,

Wim

2008/4/4, Tim Nguyen [EMAIL PROTECTED]:

 Thank you! It is similar to what I wanted to do. This is more like the
 solution for one class. Is there anyway to check for all classes? I have
 hundreds of classes and I want to have an util that I can just replace the
 current logging  (e.g: logger.debug(String)) with LogUtil (e.g:
 LogUtil.debug(String) and it does the trick. That way I can just replace
 All the logger with LogUtil :)

 Thanks again for your help!


 - Original Message 
 From: Robert Pepersack [EMAIL PROTECTED]
 To: Log4J Users List log4j-user@logging.apache.org
 Sent: Friday, April 4, 2008 12:14:30 PM
 Subject: Re: Log Utility

 Hi Tim,

 The Logger class has a way of checking the level first.

 First put this in your instance variables:

 private static final Logger logger =
 Logger.getLogger(my.package.MyClass);

 private final boolean debug = logger.isDebugEnabled();

 Then put this in your method:

 if (this.debug)
 {
 logger.debug(new String(test));
 }

 Hope this helps.

 Robert Pepersack
 Senior Lead Developer
 Maryland Insurance Administration
 410-468-2054

  Tim Nguyen [EMAIL PROTECTED] 04/04/2008 3:02 PM 
 Hi,

 I am writing a Log Utility to check the log level first before creating a
 string object. For example, if my log level is INFO, and I call:

 log.debug(new String(test));

 It will still instantiate the String object even thought it doesn't log
 anything.

 So I would like to write an Utility to check the level first, if the log
 level is lower, then I don't have to instantiate the object and just skip
 it.
 Anybody knows what is the easy way to do that?

 Thanks,





   
 
 You rock. That's why Blockbuster's offering you one month of Blockbuster
 Total Access, No Cost.
 http://tc.deals.yahoo.com/tc/blockbuster/text5.com


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]








   
 
 You rock. That's why Blockbuster's offering you one month of Blockbuster
 Total Access, No Cost.
 http://tc.deals.yahoo.com/tc/blockbuster/text5.com


Re: Log Utility

2008-04-04 Thread Robert Pepersack
Hi Tim,

The Logger class has a way of checking the level first.

First put this in your instance variables:

private static final Logger logger = Logger.getLogger(my.package.MyClass);

private final boolean debug = logger.isDebugEnabled();

Then put this in your method:

if (this.debug)
{
logger.debug(new String(test));
}

Hope this helps.

Robert Pepersack
Senior Lead Developer
Maryland Insurance Administration
410-468-2054

 Tim Nguyen [EMAIL PROTECTED] 04/04/2008 3:02 PM 
Hi,

I am writing a Log Utility to check the log level first before creating a 
string object. For example, if my log level is INFO, and I call:

log.debug(new String(test));

It will still instantiate the String object even thought it doesn't log 
anything.

So I would like to write an Utility to check the level first, if the log level 
is lower, then I don't have to instantiate the object and just skip it.
Anybody knows what is the easy way to do that?

Thanks,




  

You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Log Utility

2008-04-04 Thread Tim Nguyen
Thank you! It is similar to what I wanted to do. This is more like the solution 
for one class. Is there anyway to check for all classes? I have hundreds of 
classes and I want to have an util that I can just replace the current logging  
(e.g: logger.debug(String)) with LogUtil (e.g: LogUtil.debug(String) and it 
does the trick. That way I can just replace All the logger with LogUtil :)

Thanks again for your help!

- Original Message 
From: Robert Pepersack [EMAIL PROTECTED]
To: Log4J Users List log4j-user@logging.apache.org
Sent: Friday, April 4, 2008 12:14:30 PM
Subject: Re: Log Utility

Hi Tim,

The Logger class has a way of checking the level first.

First put this in your instance variables:

private static final Logger logger = Logger.getLogger(my.package.MyClass);

private final boolean debug = logger.isDebugEnabled();

Then put this in your method:

if (this.debug)
{
logger.debug(new String(test));
}

Hope this helps.

Robert Pepersack
Senior Lead Developer
Maryland Insurance Administration
410-468-2054

 Tim Nguyen [EMAIL PROTECTED] 04/04/2008 3:02 PM 
Hi,

I am writing a Log Utility to check the log level first before creating a 
string object. For example, if my log level is INFO, and I call:

log.debug(new String(test));

It will still instantiate the String object even thought it doesn't log 
anything.

So I would like to write an Utility to check the level first, if the log level 
is lower, then I don't have to instantiate the object and just skip it.
Anybody knows what is the easy way to do that?

Thanks,




  

You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







  

You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

Re: Log Utility

2008-04-04 Thread Robert Pepersack
The Logger.isDebugEnabled() method applies to all of the classes that use your 
configured log4j repository.  If you have your all of your loggers set to 
DEBUG, then Logger.isDebugEnabled() will return true, no matter what class it 
gets called in. 

Robert Pepersack
Senior Lead Developer
Maryland Insurance Administration
410-468-2054

 Tim Nguyen [EMAIL PROTECTED] 04/04/2008 4:35 PM 
Thank you! It is similar to what I wanted to do. This is more like the solution 
for one class. Is there anyway to check for all classes? I have hundreds of 
classes and I want to have an util that I can just replace the current logging  
(e.g: logger.debug(String)) with LogUtil (e.g: LogUtil.debug(String) and it 
does the trick. That way I can just replace All the logger with LogUtil :)

Thanks again for your help!

- Original Message 
From: Robert Pepersack [EMAIL PROTECTED]
To: Log4J Users List log4j-user@logging.apache.org
Sent: Friday, April 4, 2008 12:14:30 PM
Subject: Re: Log Utility

Hi Tim,

The Logger class has a way of checking the level first.

First put this in your instance variables:

private static final Logger logger = Logger.getLogger(my.package.MyClass);

private final boolean debug = logger.isDebugEnabled();

Then put this in your method:

if (this.debug)
{
logger.debug(new String(test));
}

Hope this helps.

Robert Pepersack
Senior Lead Developer
Maryland Insurance Administration
410-468-2054

 Tim Nguyen [EMAIL PROTECTED] 04/04/2008 3:02 PM 
Hi,

I am writing a Log Utility to check the log level first before creating a 
string object. For example, if my log level is INFO, and I call:

log.debug(new String(test));

It will still instantiate the String object even thought it doesn't log 
anything.

So I would like to write an Utility to check the level first, if the log level 
is lower, then I don't have to instantiate the object and just skip it.
Anybody knows what is the easy way to do that?

Thanks,




  

You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com 


-
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 







  

You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Log Utility

2008-04-04 Thread Gary Gregory
Also note that

log.debug(new String(test))

is the same as

log.debug(test);

and in general:

new String(test)

is the same as

test

Gary

 -Original Message-
 From: Robert Pepersack [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 04, 2008 1:44 PM
 To: Log4J Users List
 Subject: Re: Log Utility

 The Logger.isDebugEnabled() method applies to all of the classes that use your
 configured log4j repository.  If you have your all of your loggers set to 
 DEBUG,
 then Logger.isDebugEnabled() will return true, no matter what class it gets 
 called
 in.

 Robert Pepersack
 Senior Lead Developer
 Maryland Insurance Administration
 410-468-2054

  Tim Nguyen [EMAIL PROTECTED] 04/04/2008 4:35 PM 
 Thank you! It is similar to what I wanted to do. This is more like the 
 solution for
 one class. Is there anyway to check for all classes? I have hundreds of 
 classes and
 I want to have an util that I can just replace the current logging  (e.g:
 logger.debug(String)) with LogUtil (e.g: LogUtil.debug(String) and it 
 does the
 trick. That way I can just replace All the logger with LogUtil :)

 Thanks again for your help!

 - Original Message 
 From: Robert Pepersack [EMAIL PROTECTED]
 To: Log4J Users List log4j-user@logging.apache.org
 Sent: Friday, April 4, 2008 12:14:30 PM
 Subject: Re: Log Utility

 Hi Tim,

 The Logger class has a way of checking the level first.

 First put this in your instance variables:

 private static final Logger logger = 
 Logger.getLogger(my.package.MyClass);

 private final boolean debug = logger.isDebugEnabled();

 Then put this in your method:

 if (this.debug)
 {
 logger.debug(new String(test));
 }

 Hope this helps.

 Robert Pepersack
 Senior Lead Developer
 Maryland Insurance Administration
 410-468-2054

  Tim Nguyen [EMAIL PROTECTED] 04/04/2008 3:02 PM 
 Hi,

 I am writing a Log Utility to check the log level first before creating a 
 string
 object. For example, if my log level is INFO, and I call:

 log.debug(new String(test));

 It will still instantiate the String object even thought it doesn't log 
 anything.

 So I would like to write an Utility to check the level first, if the log 
 level is lower,
 then I don't have to instantiate the object and just skip it.
 Anybody knows what is the easy way to do that?

 Thanks,





 __
 __
 You rock. That's why Blockbuster's offering you one month of Blockbuster Total
 Access, No Cost.
 http://tc.deals.yahoo.com/tc/blockbuster/text5.com


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]








 __
 __
 You rock. That's why Blockbuster's offering you one month of Blockbuster Total
 Access, No Cost.
 http://tc.deals.yahoo.com/tc/blockbuster/text5.com


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]