> I'm planning an application with an ear with an war and an
> jar (entity beans).
> I'd like to log the output in another location than the server.log.
> What is the preferred way in glassfish? I've seen many sites
> in google with problems using log4j as logger.
I use Commons Logging and underneath that just the JDK logging atm (I
also had problems with Log4J not releasing resources correctly, or me
not releasing resources correctly, one of them), and as part of system
startup also attach some of my own handlers so I can log to files
elsewhere. The GF ones I found too verbose and there's no way to
configure them afaik (thought I had a good sed/tail pipe working for a
while but ended up culling out too much); the log definition class below
just holds a logger name and file name pattern to use, and the custom
SystemLogFormatter just logs how I want it:
LogManager logManager = LogManager.getLogManager();
try {
for (SystemLogDefinition loggerDefinition : loggerDefinitions)
{
String fileName = loggerDefinition.getFilePattern();
FileHandler handler = new FileHandler(
fileName, 10 * Constants.BYTES_MB, 3, true);
for (String loggerName : loggerDefinition.getLoggerList()) {
Logger logger = logManager.getLogger(loggerName);
if (logger != null) {
handler.setFormatter(new SystemLogFormatter());
logger.addHandler(handler);
logger.info("Started logger");
}
}
}
} catch (IOException ex) {
throw new ApplicationRuntimeException(ex);
}
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.