I have 2 glassfish. "GFnb" starts from Netbean for development and testing. "GF" starts from Windows service for real production run. Because of this I always make sure both settings are the same, at least I tried my best. And they works as expected, i.e. with stock log settings both record the same logs. Recently, I try to change the format of the logs and find that my log setting works on "GFnb" but not on "GF". I post my settings below which apply to both systems. Please advise if there is other log settings that I've missed.
My typical log coding:
import java.util.logging.Logger;
static final Logger log = Logger.getLogger("mylog");
log.info("processing abc");
My domain.xml, together with other JVM options:
<jvm-options>-Djava.util.logging.SimpleFormatter.format=%1$tF %1$tT.%1$tL|%4$s|%3$s|%5$s|%6$s%n</jvm-options>
My logging.properties at domain's config folder:
handlers=java.util.logging.ConsoleHandler, java.util.logging.FileHandler
handlerServices=com.sun.enterprise.server.logging.GFFileHandler
java.util.logging.FileHandler.pattern=myapp%g_%u.log
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.limit=2000000
java.util.logging.FileHandler.count=3
java.util.logging.FileHandler.append = true
com.sun.enterprise.server.logging.GFFileHandler.formatter=com.sun.enterprise.server.logging.UniformLogFormatter
....
First few lines of myapp0_0.log at "GFnb" domain1/config:
2015-09-23 15:06:38.560|INFO|javax.enterprise.logging|Running GlassFish Version: GlassFish Server Open Source Edition 4.0 (build 89)|
2015-09-23 15:06:38.560|INFO|javax.enterprise.logging|Server log file is using Formatter class: com.sun.enterprise.server.logging.UniformLogFormatter|
2015-09-23 15:06:38.672|INFO|javax.enterprise.system.core.security.com.sun.enterprise.security.auth.realm|SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.|
2015-09-23 15:06:38.672|INFO|javax.enterprise.system.core.security.com.sun.enterprise.security.auth.realm|SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.|
2015-09-23 15:06:38.672|INFO|javax.enterprise.system.core.security.com.sun.enterprise.security.auth.realm|SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.|
2015-09-23 15:06:39.048|INFO|javax.enterprise.system.core|Grizzly Framework 2.3.1 started in: 62ms - bound to [/0.0.0.0:8,080]|
.....
First few lines of myapp0_0.log at "GF" domain1/config (all lines are the same):
${1$tF }1$tT.${1$tL|}4$s|${3$s|}5$s|${6$s}n${1$tF 1$tT.${1$tL|}4$s|${3$s|}5$s|${6$s}n
EDIT: I've further tested my setup and found that, on the GFnb machine, if I start GFnb as a Windows service, it has the same problem as GF. If I start via Netbean, it has no problem.
@jmehrens, thanks for the reply. I cannot get the idea from the link. My setup is in effect, except that instead of formatting the msg it "echo" the format string. If I change the .format in the JVM option, it does change the output, but still no msg contents.