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

Java RepositorySelector类代码示例

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

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



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

示例1: install

import org.apache.log4j.spi.RepositorySelector; //导入依赖的package包/类
/**
 * Installs the ThreadLogManager in this system.
 * <p>
 * Note that this can fail if some other framework has done a call to LogManager.setRepositorySelector with a guard already.
 * 
 * @param logMessageModifier
 *            optional implementation of LogMessageModifier which allows messages to be modified should they be affected by a threadlocal loglevel overwrite. This
 *            allows for example for messages to be prepended with a token so that they can be easier found in the log
 */
void install(final LogMessageModifier logMessageModifier) {

    try {
        final LoggerFactory loggerFactory = new LoggerFactory() {

            @SuppressWarnings("synthetic-access")
            @Override
            public Logger makeNewLoggerInstance(String name) {
                return new ThreadLocalAwareLogger(name, threadLocalLogLevel_, logMessageModifier);
            }
        };

        final Logger originalRootLogger = LogManager.getRootLogger();

        final LoggerRepository parentRepository = originalRootLogger.getLoggerRepository();

        final LoggerRepository repository = new ThreadLocalAwareLoggerRepository(originalRootLogger, parentRepository, loggerFactory);

        LogManager.setRepositorySelector(new RepositorySelector() {

            @Override
            public LoggerRepository getLoggerRepository() {
                return repository;
            }
        }, guard);
    } catch (IllegalArgumentException re) {
        // thrown by LogManager.setRepositorySelector
        log.error("Could not install ThreadLocalLogLevelManager", re);
    }

}
 
开发者ID:huihoo,项目名称:olat,代码行数:41,代码来源:ThreadLocalLogLevelManager.java


示例2: init

import org.apache.log4j.spi.RepositorySelector; //导入依赖的package包/类
public static synchronized void init(ServletContext servletContext)
        throws ServletException {
    if (!initialized) // set the global RepositorySelector
    {
        defaultRepository = LoggerFactory.getLoggerRepository();
        RepositorySelector theSelector = new AppRespositorySelector();
        LogManager.setRepositorySelector(theSelector, guard);
        initialized = true;
    }

    Hierarchy hierarchy = new Hierarchy(new RootLogger(Level.DEBUG));
    loadLog4JConfig(servletContext, hierarchy);
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    repositories.put(loader, hierarchy);
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:16,代码来源:AppRespositorySelector.java


示例3: setRepositorySelector

import org.apache.log4j.spi.RepositorySelector; //导入依赖的package包/类
/**
   Sets <code>LoggerFactory</code> but only if the correct
   <em>guard</em> is passed as parameter.
   
   <p>Initally the guard is null.  If the guard is
   <code>null</code>, then invoking this method sets the logger
   factory and the guard. Following invocations will throw a {@link
   IllegalArgumentException}, unless the previously set
   <code>guard</code> is passed as the second parameter.

   <p>This allows a high-level component to set the {@link
   RepositorySelector} used by the <code>LogManager</code>.
   
   <p>For example, when tomcat starts it will be able to install its
   own repository selector. However, if and when Tomcat is embedded
   within JBoss, then JBoss will install its own repository selector
   and Tomcat will use the repository selector set by its container,
   JBoss.  */
static
public
void setRepositorySelector(RepositorySelector selector, Object guard) 
                                               throws IllegalArgumentException {
  if((LogManager.guard != null) && (LogManager.guard != guard)) {
    throw new IllegalArgumentException(
         "Attempted to reset the LoggerFactory without possessing the guard.");
  }

  if(selector == null) {
    throw new IllegalArgumentException("RepositorySelector must be non-null.");
  }

  LogManager.guard = guard;
  LogManager.repositorySelector = selector;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:35,代码来源:LogManager.java


示例4: init

import org.apache.log4j.spi.RepositorySelector; //导入依赖的package包/类
/**
	 * Initialize that Foundation Logging library.
	 */
	static void init() {// NOPMD

		determineIfNTEventLogIsSupported();

		URL resource = null;

		final String configurationOptionStr = OptionConverter.getSystemProperty(DEFAULT_CONFIGURATION_KEY, null);

		if (configurationOptionStr != null) {
			try {
				resource = new URL(configurationOptionStr);
			} catch (MalformedURLException ex) {
				// so, resource is not a URL:
				// attempt to get the resource from the class path
				resource = Loader.getResource(configurationOptionStr);
			}
		}
		if (resource == null) {
			resource = Loader.getResource(DEFAULT_CONFIGURATION_FILE); // NOPMD
		}

		if (resource == null) {
			System.err.println("[FoundationLogger] Can not find resource: " + DEFAULT_CONFIGURATION_FILE); // NOPMD
			throw new FoundationIOException("Can not find resource: " + DEFAULT_CONFIGURATION_FILE); // NOPMD
		}

		// update the log manager to use the Foundation repository.
		final RepositorySelector foundationRepositorySelector = new FoundationRepositorySelector(FoundationLogFactory.foundationLogHierarchy);
		LogManager.setRepositorySelector(foundationRepositorySelector, null);

		// set logger to info so we always want to see these logs even if root
		// is set to ERROR.
		final Logger logger = getLogger(FoundationLogger.class);

		final String logPropFile = resource.getPath();
		log4jConfigProps = getLogProperties(resource);
		
		// select and configure again so the loggers are created with the right
		// level after the repository selector was updated.
		OptionConverter.selectAndConfigure(resource, null, FoundationLogFactory.foundationLogHierarchy);

		// start watching for property changes
		setUpPropFileReloading(logger, logPropFile, log4jConfigProps);

		// add syslog appender or windows event viewer appender
//		setupOSSystemLog(logger, log4jConfigProps);

		// parseMarkerPatterns(log4jConfigProps);
		// parseMarkerPurePattern(log4jConfigProps);
//		udpateMarkerStructuredLogOverrideMap(logger);

        AbstractFoundationLoggingMarker.init();

		updateSniffingLoggersLevel(logger);

        setupJULSupport(resource);

    }
 
开发者ID:foundation-runtime,项目名称:logging,代码行数:62,代码来源:FoundationLogger.java


示例5: setRepositorySelector

import org.apache.log4j.spi.RepositorySelector; //导入依赖的package包/类
/**
 * No-op implementation.
 * @param selector The RepositorySelector.
 * @param guard prevents calls at the incorrect time.
 * @throws IllegalArgumentException if a parameter is invalid.
 */
public static void setRepositorySelector(final RepositorySelector selector, final Object guard)
    throws IllegalArgumentException {
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:10,代码来源:LogManager.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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