简体   繁体   English

Eclipse PDE项目中的Slf4j和登录?

[英]Slf4j and logback in an eclipse PDE project?

I have added slf4j 1.6.1, logback-core-0.9.24.jar, and logback-classic-0.9.24.jar to my target platform and added them as a dependency in the MANIFEST file in a plug-in project. 我已将slf4j 1.6.1,logback-core-0.9.24.jar和logback-classic-0.9.24.jar添加到目标平台,并将它们作为依赖项添加到插件项目的MANIFEST文件中。

In the Activator I do: 在激活器中,我执行以下操作:

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Activator implements BundleActivator {
  private static final Logger logger = LoggerFactory.getLogger(Activator.class
      .getName());

  private static Activator defaultInstance;

  public Activator() {
    Activator.defaultInstance = this;
  }

  /*
   * (non-Javadoc)
   * 
   * @see
   * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext )
   */
  public void start(BundleContext context) throws Exception {
    System.out.println(logger.isInfoEnabled());
    System.out.println(logger.isDebugEnabled());
    System.out.println(logger.isWarnEnabled());
    System.out.println(logger.isErrorEnabled());
    logger.info("llllladasdad");
  }
  }
}

but it just prints false for all cases and nothing for the info call. 但在所有情况下它只会显示false,而在info调用中则不显示任何内容。 How do I enable logback in an eclipse PDE project? 如何在Eclipse PDE项目中启用登录功能?

You can try to force the logback configuration, reseting the default config to load your own XML config file. 您可以尝试强制执行logback配置,将默认配置重置为加载您自己的XML配置文件。 The code to do that is described in logback documentation . 登录日志文档中描述了执行此操作的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM