Logging problem, please Help !

Skip to first unread message


Dec 24, 2010, 10:07:17 PM12/24/10
to Google Web Toolkit
I am using the new Logging feature introduced in GWT 2.1.

I get this annoying line in my logs, that keeps repeating in every
other line :

"24-Dec-2010 6:58:42 PM java.util.logging.LogManager$RootLogger log"
INFO : what i am interested in
24-Dec-2010 6:58:42 PM java.util.logging.LogManager$RootLogger log
INFO: .....
24-Dec-2010 6:58:42 PM java.util.logging.LogManager$RootLogger log

I want to get rid of this,
"24-Dec-2010 6:58:42 PM java.util.logging.LogManager$RootLogger log"
because it doesnt add anything of value, the time and date is
but not that full name of the class.

does anyone know how I can do that ?
I want to see only the INFO part, not the other lines.
(time and date are interesting though)

I use these settings:
private static Logger logger = Logger.getLogger("");

and in my .gwt.xml file:

<set-property name="gwt.logging.enabled" value="TRUE"/>
<set-property name="gwt.logging.logLevel" value="ALL"/>
<set-property name="gwt.logging.consoleHandler" value="ENABLED" />
<set-property name="gwt.logging.developmentModeHandler"
value="ENABLED" />
<set-property name="gwt.logging.firebugHandler" value="ENABLED" />
<set-property name="gwt.logging.hasWidgetsHandler"
value="DISABLED" />
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<set-property name="gwt.logging.systemHandler" value="ENABLED" />
<set-property name="gwt.logging.simpleRemoteHandler"
value="ENABLED" />

I tried changing some of these properties with no luck.
please help.

David Chandler

Dec 27, 2010, 12:18:22 PM12/27/10
to google-we...@googlegroups.com
GWT uses standard java.util.logging, which lets you specify a custom
formatter in logging.properties. Perhaps this will help:



> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

David Chandler
Developer Programs Engineer, Google Web Toolkit
w: http://code.google.com/
b: http://googlewebtoolkit.blogspot.com/
t: @googledevtools

Mauro Bertapelle

Dec 27, 2010, 2:11:27 PM12/27/10
to google-we...@googlegroups.com
First you need to supply a custom formatter. Look at com.google.gwt.logging.client.TextLogFormatter for a simple example or, this is an example of a formatter that format log message in a single line:

public class CustomFormatter extends FormatterImpl {
  private boolean showStackTraces;
  private final DateTimeFormat dtFormat = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");

  public CustomFormatter(boolean showStackTraces) {
    this.showStackTraces = showStackTraces;

  public String format(LogRecord event) {
    StringBuilder message = new StringBuilder();
    message.append(getRecordInfo(event, " "));
    if (showStackTraces) {
      message.append(getStackTraceAsString(event.getThrown(), "\n", "\t"));
    return message.toString();

  protected String getRecordInfo(LogRecord event, String newline) {
    Date date = new Date(event.getMillis());
    StringBuilder s = new StringBuilder();
    s.append(" "); // comment this line to get rid of classpath name
    s.append(event.getLoggerName()); // comment this line to get rid of classpath name
    s.append(": ");
    return s.toString();

Then all you have to do is associate your custom formatter with log handlers:

public class MyGwtApp implements EntryPoint {
  private static final Logger log = Logger.getLogger(MyGwtApp.class.getName());

  // initialize logger with custom formatter
  static {
    Handler handlers[] = Logger.getLogger("").getHandlers();
    for (Handler handler : handlers) {
      handler.setFormatter(new CustomFormatter(false));


Feb 15, 2011, 7:30:13 PM2/15/11
to Google Web Toolkit

On Dec 27 2010, 12:11 pm, Mauro Bertapelle
<mauro.bertape...@gmail.com> wrote:

>   // initialize logger with custom formatter
>   static {
>     Handler handlers[] = Logger.getLogger("").getHandlers();
>     for (Handler handler : handlers) {
>       handler.setFormatter(new CustomFormatter(false));
>     }
>   }
>   ....

Am I missing something, or do log formatters not work with the log
output to the 'Console' tab in Eclipse? I never seem to have any
handlers returned from getHandlers(), but somehow I'm getting log
output there... That date/class line simply crushes readability, and
the Eclipse panel seems like an ideal place to be monitoring output...
Feel like an idiot after spending an hour fooling with this... :-(


Feb 15, 2011, 7:40:55 PM2/15/11
to Google Web Toolkit

Heck, never mind.

I had logging disabled in my gwt.xml file, and apparently that still
allows logging to happen with a default formatter in Eclipse. Once I
enabled logging, the handlers got installed and my messages are
formatted (almost) the way I want them.

[slaps head, goes looking for more coffee... ]
Reply all
Reply to author
0 new messages