users@glassfish.java.net

[gf-users] Possible to disable GFFileHandler without changing log level?

From: Joachim Kanbach <jo.ka_at_gmx.de>
Date: Wed, 9 Dec 2015 09:45:16 +0100

Hi all,

I'm looking for a way to completely prevent GFFileHandler from creating and writing to the server.log file. Having seen this: https://java.net/jira/browse/GLASSFISH-19323, I was under the assumption that merely removing the "handlerServices" property from logging.properties could achieve this. But doing that doesn't seem to have any effect at all, i.e. the log file is still created and written to.

My motivation to do this is that I'm trying to completely re-route all application and server/framework logging via the SLF4J bridge to Log4j2. This can be achieved quite easily, and I can already make Log4j2 process all JUL log events. Ultimately, I want to split my log events into application-specific log files, hence looking at Log4j2.

But at least for now, I'd like to still have a "master" server.log file that contains all the log entries. Mainly because I use Eclipse + GlassFish Tools, which simply forward the content of server.log to the Eclipse console, but also to have some sort of backup. Therefore I need GFFileHandler to stop using that file so that I can let Log4j2 write to it.

Using the following property doesn't completely solve the issue: com.sun.enterprise.server.logging.GFFileHandler.level=OFF. It seems like GFFileHandler still acquires a handle on the file since it gets created empty if it doesn't exist, however at least no log entries are written then.

A workaround I thought of is to let GFFileHandler write to a dummy file in a different location, but if there exists an easy way to just disable the I/O, that would be much better ...


Best regards,
Joachim Kanbach