Skip to content

Getting Glassfish stdout logging under control

By default, Glassfish does an ugly thing: takes an application’s stdout/stderr and wraps it into its own log with INFO level for stdout and WARN level for stderr.
Other logging facility normally log to stdout.
In the end, a log entry looks pretty stupidly (and it’s damn multiline!):

[#|2012-11-21T11:25:07.225+0200|INFO|glassfish3.1.2||_ThreadID=100;_ThreadName=Thread-2;|11:25:07.225 [http-thread-pool-8080(2)] DEBUG c.mycompany.packages.SomeClass - Finally, some useful text!

One can replace a Glassfish logging server-wide.
There’s a file in the root of Glassfish domain, it has a “handlers” property that one can swap for Logback’s handler.
Of course, this requires adding Logback JUL bridge to Glassfish classpath.

Post a Comment

Your email is never published nor shared.