Hi Steve -
If you're using a JUnit test, then it's just running java and using
the JRE implementations for any java.util.logging calls, not the GWT
emulations. I'm not sure why the setLevel method isn't working -
perhaps something with your logging.properties file? Actually - I
suspect that this is what's happening:
- Your java environment by default adds a ConsoleHandler to the
RootLogger
- Your java environment by default sets the level of the RootLogger
to INFO
- You're adding a child logger to the root logger and setting it's
level to ALL
- You log to your child logger, it logs all messages to it's
handlers (but it doesn't have any handlers, so nothing is output)
- Your child logger passes it's message up to the RootLogger, which
logs only INFO and above messages to it's handlers (the
ConsoleHandler)
- The ConsoleHandler ends up outputting INFO and above messages to
the error console, where you're looking for log messages
- The solution would be to do setLevel on the RootLogger rather than
your logger, or configure the RootLogger to have Level.ALL in your
logging.properties file and then changing the level of your child
logger should work fine.
That's my best guess, but whatever it is, it should be due to your
server side configuration of logging and independent of GWT.
- Unnur
The following information may be helpful to you if you want to get
more involved:
Essentially, Logging.gwt.xml contains an entry point class
LogConfiguration (this is not an emulated class). In it's OnModuleLoad
function, the LogConfiguration class will read your gwt.xml
properties, add the correct handlers to the root logger and set the
level of the root logger. You may be able to mock out the
LogConfiguration class somehow if you really want to test the client
side handlers. However - if you're just interested in the logging, and
you don't care about the handlers, then using your logging.properties
file to add a regular Java handler (maybe a ConsoleHandler) to the
root logger would be fine (see my comments above, I suspect your
system is already doing this for you)
If you do want to test the client side handlers, you'll probably need
to mock some of them out since they use JSNI calls to log to things
like the javascript console). You should know that things will
possibly get quite dicey since now the GWT code will be sharing a root
logger with any server side logging you have set up (this may not be a
problem in the unit test). We do some byte code rewriting tricks to
work around this in DevMode (which also uses the JRE implementations
of the java.util.logging classes rather than the GWT implementations).