3
votes

Does anyone know how I can reduce the width of each line on a glassfish log. It seems to contain lots of information that I do not need. Below is an example of one line.

[#|2012-03-04T16:00:09.537+0000|INFO|oracle-glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=94;_ThreadName=Thread-1;|16:00:09,537  INFO MyClassNameThatIsLogging:89 - LogMessageHere

All I really care about is:

  • the time at the beginning - although not even in this much deatail (2012-03-04T16:00:09.537+0000)
  • the log level (INFO)
  • The classname/line number (MyClassNameThatisLogging:89)
  • The message (LogMessageHere)

I dont care about this part

oracle-glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=94;_ThreadName=Thread-1;

Where is this configured?

I have found Install log formater in glassfish, but it seems a bit extreme. Do I really have to create my own logger?

Thanks in advance

1

1 Answers

2
votes

A custom log handler seems to be the only option here.

The glassfish admin guide does describes the log format in detail:

[#|yyyy-mm-ddThh:mm:ss.SSS-Z|Log Level|ProductName-Version|LoggerName|Key Value Pairs|Message|#]

From: Glassfish Admin Guide, Log Records

Further on it states:

By default, Oracle GlassFish Server log records are captured in a server log file using the format described in Log Records. However, you may find that you want to log messages to a different location, such as a database or a remote server, or log messages from specific loggers to your own file. This can be done by implementing a custom log handler. This section explains how to add a custom log handler to the Oracle GlassFish Server logging service.

From: Glassfish Admin Guide, Adding a Custom Logging Handler

This blog post shows an example implementation.