Question

When i run my junit jersey service tests using the grizzly framework in eclipse, the log is directed to stderr. As a result the console window grabs focus, and the log appears red.

I can't figure out the proper configuration steps. From my reading it looks like i need to add the slf4j.jar to my pom.xml and add a logging properties file somewhere? But i'm unsure which slf4j jars to add (there are many) or where to place the logging properties file.

Or, frankly, if this is the right approach in general.

p.s. also i am aware i can turn off the "show console when standard error changes" feature in eclipse, but i'd rather not paint over the problem. :)

Was it helpful?

Solution

It doesn't look to me like Grizzly used slf4j, but rather the "standard" java.util.logging framework. If that's the case, you can read about configuring it here: http://docs.oracle.com/javase/6/docs/technotes/guides/logging/overview.html#1.8

OTHER TIPS

With Eric's help above I created this class:

package org.trebor.www;

import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
import java.util.logging.Logger;

public class LoggerTrap
{
  public LoggerTrap()
  {
    Handler handler = 
      new ConsoleHandler()
    {
      {
        setOutputStream(System.out);
      }
    };

    Logger.getLogger("").addHandler(handler);
  }
}

and added this jvm arg

-Djava.util.logging.config.class=org.trebor.www.LoggerTrap

and all java.logging goes to STDOUT. In the process I've learned that I don't much like java.logging.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top