logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lutz Michael <michael.h.l...@siemens.com>
Subject RE: Can4t write logs
Date Thu, 11 Nov 2004 15:37:34 GMT

the "name" of your logger is important because it's by this name that
logging can be turned up and down in a config file.  So if you use the
"root" logger you're losing the ability to turn up logging just in your
class - you'd have to turn up the root logger and if some other class is
using log4j you might affect its settings.  You're losing much of the power
of Log4j.

So, the recommend approach is to name loggers based on the fully qualified
name of the class, such as:

import org.apache.log4j.Logger;
public class Test {
   static private final Logger logger = Logger.getLogger(Test.class);
//important line here
 public void myTestMethod() {
    logger.debug4("this is a test");
 }
}

Each class that has to log should have a private static final logger setup
like above.  This is just a "general best practice".


-----Original Message-----
From: Javier [mailto:xleyba@yahoo.com]
Sent: Thursday, November 11, 2004 10:06 AM
To: Log4J Users List
Subject: RE: Can4t write logs


> 
> One thing that's "unusual" - using the root logger. 
> It's generally
> recommended to use the getLogger method and name
> your loggers with the class
> FQCN, else you lose much of the power of Log4j (see
> http://logging.apache.org/log4j/docs/manual.html).

Thanks for your reply.

Yes, I?ve read the manual but I really don?t
understand this point..

What do you mean with use getLogger with the class.
Which class should I use ? Should I place my
application class name as a parameter to getLogger ?

My application is a little (but powerfull, jeje) class
a file...and only one.



> 
> Q: did you see the console output, and did you not
> see the output in the
> file or did you not find the file?

I see the file but nothing inside. Also, I see nothing
in console output..


thanks in advance
Javier




		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


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

-------------------------------------------------------------------------------
This message and any included attachments are from Siemens Medical Solutions 
USA, Inc. and are intended only for the addressee(s).  
The information contained herein may include trade secrets or privileged or 
otherwise confidential information.  Unauthorized review, forwarding, printing, 
copying, distributing, or using such information is strictly prohibited and may 
be unlawful.  If you received this message in error, or have reason to believe 
you are not authorized to receive it, please promptly delete this message and 
notify the sender by e-mail with a copy to Central.SecurityOffice@shs.siemens.com 

Thank you

---------------------------------------------------------------------
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