icordoba
icordoba

Reputation: 1899

Multiple apps in glassfish JUL logging to different log files?

I use java.util.logging and have multiple war apps in glassfish servers. I'd like JUL to log to a different file for each war (currently glassfish logs everything to server.log). I know this is easy to do with log4j or other logging modules, but I'd like to stick to JUL. (Would not like to discuss if JUL is my best option). Is it possible? Thanks

Upvotes: 1

Views: 1188

Answers (1)

unwichtich
unwichtich

Reputation: 13857

It is possible to append a different FileHandler to a Logger.

If you have a normal logger:

private final static Logger LOGGER = Logger.getLogger(Something.class.getName()); 

Add a new FileHandler:

Handler fh = new FileHandler("/home/file.log");
LOGGER.addHandler(fh);

Log statements will be written to the file in some XML format...

Upvotes: 1

Related Questions