5

I don´t like the output of the com.sun.enterprise.server.logging.UniformLogFormatter which might be uniform but not very helpful. So in a first step I just replaced it with the java.util.logging.SimpleFormatter. This actually works fine but for a java.lang.ClassCastException exception:

java.lang.ClassCastException: java.util.logging.SimpleFormatter cannot be cast to com.sun.enterprise.server.logging.UniformLogFormatter

Being a perfectionist I want to get rid of this exception and I wonder if I can create my own child class from com.sun.enterprise.server.logging.UniformLogFormatter and somehow install this class into glassfish.

How to install a custom log formatter into Glassfish?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Martin
  • 11,577
  • 16
  • 80
  • 110
  • Extending the logger from `java.util.logging.SimpleFormatter` is no longer a problem, but required (at least on GlassFish 3.1.2). See this http://stackoverflow.com/questions/9609380/glassfish-3-how-do-you-change-the-default-logging-format for a complete example. – Kawu Mar 14 '12 at 11:30

1 Answers1

5

Have a look at Configuring format of server log on the GlassFish forums. Basically, you need to:

  • Implement your formatter
  • Put the jar with your formatter in domain_dir/lib/ext.
  • Declare it in <mydomain>/config/logging.properties

See also

Kawu
  • 13,647
  • 34
  • 123
  • 195
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • 4
    I finally found time to create the needed loggers. However they leave a little after-taste as I needed `auto-depends.jar` and `logging.jar` to compile and run as well as `common-util.jar` to run. All from `glassfish/modules`.That opens two rhetoric question: 1) How much memory did I just waste for a simple logger. 2) Who was the idiot who implemented `com.sun.enterprise.server.logging.UniformLogFormatter` as a class instead of an interface. – Martin Feb 21 '11 at 13:07