• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NOPLoggerFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.slf4j.helpers.NOPLoggerFactory的典型用法代码示例。如果您正苦于以下问题:Java NOPLoggerFactory类的具体用法?Java NOPLoggerFactory怎么用?Java NOPLoggerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NOPLoggerFactory类属于org.slf4j.helpers包,在下文中一共展示了NOPLoggerFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initServiceLocator

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
public static ServiceLocator initServiceLocator() {
  DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
  locator.setErrorHandler(
      new DefaultServiceLocator.ErrorHandler() {
        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
          throw new RuntimeException(
              String.format(
                  "Failed to initialize service %s, implemented by %s: %s",
                  type.getName(), impl.getName(), exception.getMessage()),
              exception);
        }
      });
  locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
  locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
  locator.addService(TransporterFactory.class, FileTransporterFactory.class);
  // Use a no-op logger. Leaving this out would introduce a runtime dependency on log4j
  locator.addService(ILoggerFactory.class, NOPLoggerFactory.class);
  // Also requires log4j
  //    locator.addService(ILoggerFactory.class, Log4jLoggerFactory.class);
  return locator;
}
 
开发者ID:facebook,项目名称:buck,代码行数:23,代码来源:AetherUtil.java


示例2: SLF4JLogger

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
public SLF4JLogger(String name) {
    super(name);
    if (org.slf4j.LoggerFactory.getILoggerFactory() instanceof NOPLoggerFactory) {
        throw new AbacusException("Failed to initilze SLF4J Logger Factory");
    }

    loggerImpl = org.slf4j.LoggerFactory.getLogger(name);
}
 
开发者ID:landawn,项目名称:AbacusUtil,代码行数:9,代码来源:SLF4JLogger.java


示例3: uncaughtException

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
@Override
public void uncaughtException(Thread t, Throwable e) {
	Object context = LoggerFactory.getILoggerFactory();
	if (context instanceof NOPLoggerFactory) {
		System.err.println(String.format("Exception in thread %s", t.getName()));
		e.printStackTrace();
	} else {
		LOG.error(String.format("Exception in thread %s", t.getName()), e);
	}
}
 
开发者ID:FRC-1294,项目名称:frc2016vision,代码行数:11,代码来源:MJpegStreamer.java


示例4: login

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
@Test
public void login() throws URISyntaxException {
    if (LoggerFactory.getILoggerFactory() instanceof NOPLoggerFactory) {
        Assert.fail("No logging implementation found, using fallback NOP logger");
    }
    Logger logger = LoggerFactory.getLogger("");
    logger.info("If you see this info in the logger, everything is alright");
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:9,代码来源:LoggingDependencyTest.java


示例5: Slf4jLogFactory

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
/**
 * 构造
 * 
 * @param failIfNOP 如果未找到桥接包是否报错
 */
public Slf4jLogFactory(boolean failIfNOP) {
	super("Slf4j");
	if(false == failIfNOP){
		return;
	}

	// SFL4J writes it error messages to System.err. Capture them so that the user does not see such a message on
	// the console during automatic detection.
	final StringBuilder buf = new StringBuilder();
	final PrintStream err = System.err;
	try {
		System.setErr(new PrintStream(new OutputStream(){
			@Override
			public void write(int b) {
				buf.append((char) b);
			}
		}, true, "US-ASCII"));
	} catch (UnsupportedEncodingException e) {
		throw new Error(e);
	}

	try {
		if (LoggerFactory.getILoggerFactory() instanceof NOPLoggerFactory) {
			throw new NoClassDefFoundError(buf.toString());
		} else {
			err.print(buf);
			err.flush();
		}
	} finally {
		System.setErr(err);
	}
}
 
开发者ID:Teddy-Zhu,项目名称:SilentGo,代码行数:38,代码来源:Slf4jLogFactory.java


示例6: onActivated

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
@Override
public void onActivated(Options opts) throws BadCommandLineException {
	final ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
	if (iLoggerFactory instanceof NOPLoggerFactory) {
		System.err
				.println("You seem to be using the NOP provider of the SLF4j logging facade. "
						+ "With this configuration, log messages will be completely suppressed. "
						+ "Please consider adding a SLF4j provider (for instance slf4j-simple) to enable logging.");
	}
}
 
开发者ID:highsource,项目名称:jsonix-schema-compiler,代码行数:11,代码来源:JsonixPlugin.java


示例7: shouldNotUseNopLoggerFactory

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
@Test
public void shouldNotUseNopLoggerFactory() {
  ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();

  // verify that a SLF4J backend is used which is not the NOP logger
  assertFalse("Should not use NOPLoggerFactory", loggerFactory instanceof NOPLoggerFactory);

  // should either use slf4j-jdk14 or slf4j-jboss-logmanager
  String loggerFactoryClassName = loggerFactory.getClass().getCanonicalName();
  assertTrue("Should use slf4j-jdk14 or slf4j-jboss-logmanager",
      JDK14_LOGGER_FACTORY.equals(loggerFactoryClassName) || JBOSS_SLF4J_LOGGER_FACTORY.equals(loggerFactoryClassName));
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:13,代码来源:Slf4jClassloadingTest.java


示例8: maybeInitializeLogback

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
/**
 * Initializes Logback framework using the specified configuration file.
 * If the configuration file does not exist, or cannot be read, then this method logs
 * the problem and returns.
 *
 * @param servletCtx a servlet context.
 */
private void maybeInitializeLogback( ServletContext servletCtx )
{
  // non-expanded logback config file location
  String configLocation = servletCtx.getInitParameter( INIT_PARAM_CONFIG_LOCATION );

  String expandedConfigLocation = expandProperties( configLocation, servletCtx );
  File configLocationFile = new File( expandedConfigLocation );

  if ( configLocationFile.exists() || configLocationFile.isFile() )
  {
    if ( configLocationFile.canRead() )
    {
      ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
      if ( loggerFactory instanceof LoggerContext )
      {
        log.info( "About to initialize Logback using config file: {}", configLocationFile );

        LoggerContext context = (LoggerContext) loggerFactory;
        JoranConfigurator jc = new JoranConfigurator();
        jc.setContext( context );
        context.reset();

        context.putProperty( "logback.config.dir", configLocationFile.getParentFile().getAbsolutePath() );

        try
        {
          jc.doConfigure( configLocationFile );

          log.info( "Successfully initialized Logback using config file: {}", configLocationFile );
        }
        catch ( JoranException e )
        {
          log.error( "Error initializing Logback from: " + configLocationFile, e );
        }
      }
      else
      {
        if ( loggerFactory instanceof NOPLoggerFactory )
        {
          // need to use System.out, otherwise the message would have been silently swallowed by the NOPLogger
          System.out.println(
              "Logback cannot be initialized as SLF4J is not statically bound to any logging framework implementation. See system error output for possible SLF4J errors." );

          // print SLF4J LoggerFactory class info
          System.out.println(
              "SLF4J LoggerFactory class info: " + Debug.getClassInfo( LoggerFactory.class ) );
        }
        else
        {
          log.warn(
              "Logback cannot be initialized as SLF4J is not statically bound to Logback implementation. Bound SLF4J logger factory: {}",
              loggerFactory.getClass().getName() );

          // log SLF4J LoggerFactory class info
          log.warn( "SLF4J LoggerFactory class info: {}", Debug.getClassInfo( LoggerFactory.class ) );
        }
      }
    }
    else
    {
      log.info( "Logback configuration file: {} exists, but cannot be read. Logback configuration not changed.",
          configLocationFile );
    }
  }
  else
  {
    log.info( "Logback configuration file: {} not found. Logback configuration not changed.", configLocationFile );
  }
}
 
开发者ID:quartzdesk,项目名称:quartzdesk-executor,代码行数:77,代码来源:LogbackInitContextListener.java


示例9: StaticLoggerBinder

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
private StaticLoggerBinder() {
  loggerFactory = new NOPLoggerFactory();
}
 
开发者ID:JabJabJab,项目名称:Sledgehammer,代码行数:4,代码来源:StaticLoggerBinder.java


示例10: getLoggerFactory

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
@Override
public ILoggerFactory getLoggerFactory() {
  return new NOPLoggerFactory();
}
 
开发者ID:aol,项目名称:vulcan,代码行数:5,代码来源:StaticLoggerBinder.java


示例11: getLoggerFactoryClassStr

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
@Override
public String getLoggerFactoryClassStr() {
  return NOPLoggerFactory.class.getName();
}
 
开发者ID:aol,项目名称:vulcan,代码行数:5,代码来源:StaticLoggerBinder.java


示例12: StaticLoggerBinder

import org.slf4j.helpers.NOPLoggerFactory; //导入依赖的package包/类
private StaticLoggerBinder() {
    loggerFactory = new NOPLoggerFactory();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:4,代码来源:StaticLoggerBinder.java



注:本文中的org.slf4j.helpers.NOPLoggerFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PropertyIterator类代码示例发布时间:2022-05-21
下一篇:
Java OutputFile类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap