Logging in jsf

I have a jsf application with several pages and backing beans. I am also using a stateless session facade.

How can i use logging in the application?

I plan to use java.util.logging.logger as follows:

public static Logger logger(String loggingResourceName) throws Exception {

//refer Filehandler javadoc

//limit - the maximum number of bytes to write to any one file

//count - the number of files to use

//"%u - a unique number to resolve conflicts

FileHandler fileHandler=new FileHandler("log%u.txt", 500000, 10,true);

//use SimpleFormatter / XMLFormatter

fileHandler.setFormatter(new java.util.logging.SimpleFormatter()) ;

LogManager lm = LogManager.getLogManager();

Logger logger = Logger.getLogger(loggingResourceName);

//Message levels lower than this value will be discarded.

logger.setLevel(Level.INFO);

logger.addHandler(fileHandler);

//register logger

lm.addLogger(logger);

return logger;

}

Where should i place this method? Backing beans or session facade?

Thanks,

kal

[1120 byte] By [kal132a] at [2007-11-27 5:01:10]
# 1
It just depends on what exactly you want to log. It actually doesn't matter that much. Just think twice about the impacts and the maintainability.
BalusCa at 2007-7-12 10:18:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

I have figured out how to use the logger. But only problem is, can i use same logger object for logging both web component and the ejb beans? I am using session scope for the backing beans, is there anyway that i can store the logger in the session and use the same for object for all backing beans and also for session facade?

Thanks,

kal

kal132a at 2007-7-12 10:18:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...