当前位置: 首页>>代码示例>>Java>>正文


Java LogFactory类代码示例

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


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

示例1: UrlRewritingResponseWrapper

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
/**
 * Basic constructor.
 * 
 * pock: For BES we use a new server for every request. We can't determine
 * this server from the serverChain --> use the server of the request as
 * parameter (Bug 5487)
 * 
 * @param response
 *            The response we are wrapping
 * @param server
 *            The server that was matched
 * @param ownHostName
 *            String we are rewriting servers to
 * @throws IOException
 *             When there is a problem with the streams
 */
public UrlRewritingResponseWrapper(HttpServletResponse response,
		Server server, String ownHostName, String contextPath,
		ServerChain serverChain) throws IOException {
	super(response);
	this.server = server;
	this.ownHostName = ownHostName;
	this.contextPath = contextPath;
	this.serverChain = serverChain;

	log = LogFactory.getLog(UrlRewritingResponseWrapper.class);
	outStream = new UrlRewritingOutputStream(response.getOutputStream(),
			contextPath, response
					.getCharacterEncoding());
	outWriter = new PrintWriter(outStream);
	originalWriter = new PrintWriter(response.getOutputStream());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:33,代码来源:UrlRewritingResponseWrapper.java

示例2: contextDestroyed

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
public void contextDestroyed(ServletContextEvent contextEvent) {
	try {
		LOGGER.info("Start shutting down ORS and releasing resources.");

		if (RoutingProfileManagerStatus.isReady())
			RoutingProfileManager.getInstance().destroy();

		LocationsDataProviderFactory.releaseProviders();
		StatisticsProviderFactory.releaseProviders();
		
		LogFactory.release(Thread.currentThread().getContextClassLoader());

		try {
			System.gc();
			System.runFinalization();
			System.gc();
			System.runFinalization();
		} catch(Throwable t) {
			LOGGER.error("Failed to perform finalization.");
			t.printStackTrace();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:26,代码来源:ORSInitContextListener.java

示例3: spyOnNameService

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
/**
 * Spy on the Java DNS infrastructure.
 * This likely only works on Sun-derived JDKs, but uses JUnit's
 * Assume functionality so that any tests using it are skipped on
 * incompatible JDKs.
 */
private NameService spyOnNameService() {
  try {
    Field f = InetAddress.class.getDeclaredField("nameServices");
    f.setAccessible(true);
    Assume.assumeNotNull(f);
    @SuppressWarnings("unchecked")
    List<NameService> nsList = (List<NameService>) f.get(null);

    NameService ns = nsList.get(0);
    Log log = LogFactory.getLog("NameServiceSpy");
    
    ns = Mockito.mock(NameService.class,
        new GenericTestUtils.DelegateAnswer(log, ns));
    nsList.set(0, ns);
    return ns;
  } catch (Throwable t) {
    LOG.info("Unable to spy on DNS. Skipping test.", t);
    // In case the JDK we're testing on doesn't work like Sun's, just
    // skip the test.
    Assume.assumeNoException(t);
    throw new RuntimeException(t);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TestDFSClientFailover.java

示例4: VersionInfo

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
protected VersionInfo(String component) {
  info = new Properties();
  String versionInfoFile = component + "-version-info.properties";
  InputStream is = null;
  try {
    is = Thread.currentThread().getContextClassLoader()
      .getResourceAsStream(versionInfoFile);
    if (is == null) {
      throw new IOException("Resource not found");
    }
    info.load(is);
  } catch (IOException ex) {
    LogFactory.getLog(getClass()).warn("Could not read '" +
        versionInfoFile + "', " + ex.toString(), ex);
  } finally {
    IOUtils.closeStream(is);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:VersionInfo.java

示例5: setViaHeader

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
/**
 * Will set the via header with this proxies data to the response.
 * 
 * @param response
 *            The response we set the header for
 */
private void setViaHeader(HttpServletResponse response) {
    String serverHostName = "jEasyReverseProxy";
    try {
        serverHostName = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
        LogFactory.getLog(RequestHandlerBase.class).error(
                "Couldn't get the hostname needed for header Via", e);
    }

    Header originalVia = method.getResponseHeader("via");
    StringBuffer via = new StringBuffer("");
    if (originalVia != null) {
        via.append(originalVia.getValue()).append(", ");
    }
    via.append(method.getStatusLine().getHttpVersion()).append(" ").append(
            serverHostName);

    response.setHeader("via", via.toString());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:26,代码来源:ResponseHandlerBase.java

示例6: doCreateLogger

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
private static Log doCreateLogger(Class<?> logName) {
	Log logger;

	ClassLoader ccl = Thread.currentThread().getContextClassLoader();
	// push the logger class classloader (useful when dealing with commons-logging 1.0.x
	Thread.currentThread().setContextClassLoader(logName.getClassLoader());
	try {
		logger = LogFactory.getLog(logName);
	} catch (Throwable th) {
		logger = new SimpleLogger();
		logger
				.fatal(
						"logger infrastructure not properly set up. If commons-logging jar is used try switching to slf4j (see the FAQ for more info).",
						th);
	} finally {
		Thread.currentThread().setContextClassLoader(ccl);
	}
	return logger;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:20,代码来源:LogUtils.java

示例7: DefaultRequestDirector

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
@Deprecated
public DefaultRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            new DefaultRedirectStrategyAdaptor(redirectHandler),
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:DefaultRequestDirector.java

示例8: logger

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
/**
 * <p>Returns the <code>Log</code>.
 */
private Log logger() {
    if (logger == null) {
        logger = LogFactory.getLog(LazyDynaBean.class);
    }
    return logger;
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:10,代码来源:LazyDynaBean.java

示例9: getPrimitiveType

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
/**
 * Gets the class for the primitive type corresponding to the primitive wrapper class given.
 * For example, an instance of <code>Boolean.class</code> returns a <code>boolean.class</code>.
 * @param wrapperType the
 * @return the primitive type class corresponding to the given wrapper class,
 * null if no match is found
 */
public static Class<?> getPrimitiveType(final Class<?> wrapperType) {
    // does anyone know a better strategy than comparing names?
    if (Boolean.class.equals(wrapperType)) {
        return boolean.class;
    } else if (Float.class.equals(wrapperType)) {
        return float.class;
    } else if (Long.class.equals(wrapperType)) {
        return long.class;
    } else if (Integer.class.equals(wrapperType)) {
        return int.class;
    } else if (Short.class.equals(wrapperType)) {
        return short.class;
    } else if (Byte.class.equals(wrapperType)) {
        return byte.class;
    } else if (Double.class.equals(wrapperType)) {
        return double.class;
    } else if (Character.class.equals(wrapperType)) {
        return char.class;
    } else {
        final Log log = LogFactory.getLog(MethodUtils.class);
        if (log.isDebugEnabled()) {
            log.debug("Not a known primitive wrapper class: " + wrapperType);
        }
        return null;
    }
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:34,代码来源:MethodUtils.java

示例10: VersionInfo

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
protected VersionInfo(String component) {
  info = new Properties();
  String versionInfoFile = component + "-version-info.properties";
  InputStream is = null;
  try {
    is = ThreadUtil.getResourceAsStream(versionInfoFile);
    info.load(is);
  } catch (IOException ex) {
    LogFactory.getLog(getClass()).warn("Could not read '" +
        versionInfoFile + "', " + ex.toString(), ex);
  } finally {
    IOUtils.closeStream(is);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:VersionInfo.java

示例11: testServerSaslNoClientSasl

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
@Test
public void testServerSaslNoClientSasl() throws Exception {
  HdfsConfiguration clusterConf = createSecureConfig(
    "authentication,integrity,privacy");
  // Set short retry timeouts so this test runs faster
  clusterConf.setInt(DFSConfigKeys.DFS_CLIENT_RETRY_WINDOW_BASE, 10);
  startCluster(clusterConf);
  HdfsConfiguration clientConf = new HdfsConfiguration(clusterConf);
  clientConf.set(DFS_DATA_TRANSFER_PROTECTION_KEY, "");

  LogCapturer logs = GenericTestUtils.LogCapturer.captureLogs(
      LogFactory.getLog(DataNode.class));
  try {
    doTest(clientConf);
    Assert.fail("Should fail if SASL data transfer protection is not " +
        "configured or not supported in client");
  } catch (IOException e) {
    GenericTestUtils.assertMatches(e.getMessage(), 
        "could only be replicated to 0 nodes");
  } finally {
    logs.stopCapturing();
  }

  GenericTestUtils.assertMatches(logs.getOutput(),
      "Failed to read expected SASL data transfer protection " +
      "handshake from client at");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestSaslDataTransfer.java

示例12: testJar

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
@Test
public void testJar() throws Exception {

  //picking a class that is for sure in a JAR in the classpath
  String jar = JarFinder.getJar(LogFactory.class);
  Assert.assertTrue(new File(jar).exists());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:8,代码来源:TestJarFinder.java

示例13: quietlyCallListener

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
private static Future<?> quietlyCallListener(final ProgressListener listener,
        final ProgressEvent event) {
    try {
        listener.progressChanged(event);
    } catch(Throwable t) {
        // That's right, we need to suppress all errors so as to be on par
        // with the async mode where all failures will be ignored.
        LogFactory.getLog(SDKProgressPublisher.class)
            .debug("Failure from the event listener", t);
    }
    return null;
}
 
开发者ID:tencentyun,项目名称:cos-java-sdk-v5,代码行数:13,代码来源:SDKProgressPublisher.java

示例14: CloudControllerClientImpl

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
public CloudControllerClientImpl(URL cloudControllerUrl, RestTemplate restTemplate, OauthClient oauthClient,
    LoggregatorClient loggregatorClient, CloudCredentials cloudCredentials, CloudSpace sessionSpace) {
    logger = LogFactory.getLog(getClass().getName());

    initialize(cloudControllerUrl, restTemplate, oauthClient, loggregatorClient, cloudCredentials);

    this.sessionSpace = sessionSpace;
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:9,代码来源:CloudControllerClientImpl.java

示例15: enableBouncyCastle

import org.apache.commons.logging.LogFactory; //导入依赖的package包/类
public static synchronized void enableBouncyCastle() {
    if (isBouncyCastleAvailable()) {
        return;
    }
    try {
        @SuppressWarnings("unchecked")
        Class<Provider> c = (Class<Provider>)Class.forName(BC_PROVIDER_FQCN);
        Provider provider = c.newInstance();
        Security.addProvider(provider);
    } catch (Exception e) {
        LogFactory.getLog(CryptoRuntime.class).debug(
                "Bouncy Castle not available", e);
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:CryptoRuntime.java


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