Install log formater in glassfish

2019-02-18 08:38发布

问题:

I don´t like the output of the com.sun.enterprise.server.logging.UniformLogFormatter which might be uniform but not very helpfull. So in a first step I just replaced it with the java.util.logging.SimpleFormatter. This actualy 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

Beeing a perfectionist I want to get rid of this exeption 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.

But I could not find any information on how to install a custom log formater into Glassfish. Does anybody have a pointer on this subject?

回答1:

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

  • Configuring Logging