grizzly logs to stderr, annoying in eclipse

时间秒杀一切 提交于 2019-12-10 19:54:52

问题


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. :)


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/9088111/grizzly-logs-to-stderr-annoying-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!