aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes How to use Log4j implement singleton ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "How to use Log4j implement singleton ?" Watch "How to use Log4j implement singleton ?" New topic
Author

How to use Log4j implement singleton ?

lyo Yashnoo
Ranch Hand

Joined: Sep 15, 2003
Posts: 50
Hi everyone:
I want to implement a singleton pattern while using Log4j.But what puzzle me is it need a Class as its argument while create a Logger object.For example:
Logger log=Logger.getLogger(XXX.class);
But the singleton pattern is:
///////////////////////////////////logFactory.java//////////////////
public class logfactory{
private static Logger log=null;
private logfactory(){
log=Logger.getLogger(???)
}
public static Logger getInstance(){
................what code?...... }
How I get the argument(XXX.class) to the constructor?
If I change the code to :
/////////////////////////////////////public class logfactory{
private static Logger log=null;
private logfactory(Class classname){
log=Logger.getLogger(???)
}
It can't implement what I want to.How to use singleton in Log4j?
Thks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Why this was posted in the JSP forum is beyond me. Moving to Other Java APIs.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use Log4j implement singleton ?