The question originated from here: http://www.java.net/forum/topic/glassfish/glassfish/configuring-glassfish-logging-format – without an answer.
The default GlassFish 3 logging format is very annoying, much too long.
[#|2012-03-02T09:22:03.165+0100|SEVERE|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=113;_ThreadName=AWT-EventQueue-0;| MESSAGE... ]
This is just a horrible default IMO. The docs just explain all the fields, but not how to change the format: http://docs.oracle.com/cd/E18930_01/html/821-2416/abluk.html
Note, that I deploy SLF4J along with my webapp which should pick up the format as well.
How do you change the logging format?
FYI:
The links here are outdated: Install log formater in glassfish…
The question here hasn’t been answered: How to configure GlassFish logging to show milliseconds in timestamps?…
The posting here resulted in nothing: http://www.java.net/forum/topic/glassfish/glassfish/cant-seem-configure-…
It looks like GlassFish logging configuration is an issue of its own. Can anybody help?
The solution seems to be the first SO posting here: Install log formater in glassfish
I’ve hacked together a simple log formatter (adjust at will):
It even fixes the double newline problem on Windows machines.
I got this to work by putting the JAR into
domain/lib/extat first, but for newer tries, whatever the reason is, I only keep getting a ClassNotFoundException now:I saw the new format for a few tries, but the it stopped to work – strange.
I’ve attached the JAR as is in my original GlassFish forum post. I’ve basically just used my ZIP tool and renamed it to JAR, but this shouldn’t be a problem (?). If anybody gets it to work (again) please let me know.
Note: I’m using the GlassFish plugin to start/stop the server, don’t know if this could be an issue.
Please continue any discussions in the GlassFish forum here: http://www.java.net/forum/topic/glassfish/glassfish/configuring-glassfish-logging-format
PS: sorry I needed to post the stack trace here as the GF forum is somewhat broken.
UPDATE:
Extending java.util.logging.SimpleFormatter did the trick. GlassFish now produces log entries like:
Again, on Windows: no double newlines.