0

According to the documentation I can log to the browser console with

# In your .gwt.xml file
    <inherits name="com.google.gwt.logging.Logging"/>

    # In your .java file
    Logger logger = Logger.getLogger("NameOfYourLogger");
    logger.log(Level.SEVERE, "this message should get logged");

But there is some things I don't understand.

  • I have to import java.util.logging.Logger (also java.util.logging.Level) otherwise Eclipse complains that it cannot resolve type. Is this normal?
  • Also I don't understand how to set the logging level - according to the doc I can set

    <set-property name="gwt.logging.logLevel" value="SEVERE"/>

    in the gwt.xml file but if I set the level to FINEST and then log something with level FINE it doesn't show. However if I log something with Level.SEVERE it shows up in the console, there is definitely something happening. I'm just not sure about the connections.

2 Answers 2

1

I have to import java.util.logging.Logger (also java.util.logging.Level)

Yes, Java requires you to import the classes you are going to use, unless they are part of the language itself.

Also I don't understand how to set the logging level - according to the doc I can set

<set-property name="gwt.logging.logLevel" value="SEVERE"/>

I believe you can set this to any level you want - if you set it there to FINEST (and don't change it anywhere else), then all logging (including FINE) will be written to the console. Be sure to put this after the <inherits> statement for the logging tool itself.

Additionally, you'll want to be careful of what you've set gwt.logging.enabled to. Contrary to expectations, the values are not merely TRUE and FALSE, but also SEVERE and 'WARNING' as logLevel itself. When set to SEVERE (or WARNING) the logging functionality will actually remove all other logging, not just turn it off, resulting in a smaller compiled output suitable for production. It defaults to FALSE without any inherits statements for logging, and SEVERE with either Logging or LoggingDisabled, so you likely need to enable it in your own .gwt.xml (again, after your inherits statements).

<set-property name="gwt.logging.enabled" value="TRUE" />
Sign up to request clarification or add additional context in comments.

1 Comment

I didn't have time to test yesterday but I got around today and I had to set the gwt.logging.enabled to TRUE and then it worked - so I guess default seems to be SEVERE.
0

1.

java.util.logging.Logger is Java standard API since 1.4, so the type must be able to resolve.

2.

The levels in descending order are:

  • SEVERE (highest value)
  • WARNING
  • INFO
  • CONFIG
  • FINE
  • FINER
  • FINEST (lowest value)

If you set FINE on the property, FINE or higher level(FINE, CONFIG, INFO, WARNING and SEVERE) logs are output.

In the same way, if you set SEVERE on the property, only SEVERE level logs are output.

You can also set ALL on the propety, so all level logs are output.

1 Comment

1. The question is not whether or not java.util.logging.Logger is part of the standard api but if it's this module that I have to import in order to get the GWT logging working. 2. I know this. The question is why despite setting the logLevel to FINEST in the gwt.xml file it only logs SEVERE warnings.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.