Skip to main content

New logging formatter for Grizzly

Posted by survivant on November 3, 2008 at 6:16 AM PST

I created a new logging formatter for Grizzly, because when we were debugging a test we weren't able to trace in the log the event because the default formatter in java.util.logging doesn't print the Thread that log the event. (ouff.. that a long line)

The new formatter is : com.sun.grizzly.util.LoggingFormatter

It's based on java.util.logging.SimpleFormatter.

It's really simple to change the formatter used by java.util.logging API.

You will have to create a file (can be any name) and add this parameter to the command line.

There is already a file name that came with the JRE. (jre/lib/ You can take this file as sample for your application.

With these file, you will have only one line to change to use the new logging formatter.

* #the default logger is this add you can replace it with LoggingFormatter
* #java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
* java.util.logging.ConsoleHandler.formatter = com.sun.grizzly.util.LoggingFormatter

An example of the output will look like that :
[WorkerThreadImpl-1, Grizzly] 2008-10-08 18:49:59 [INFO] com.sun.grizzly.Controller:doSelect message

Related Topics >>