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


Java Logger.debug方法代码示例

本文整理汇总了Java中org.apache.logging.log4j.Logger.debug方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.debug方法的具体用法?Java Logger.debug怎么用?Java Logger.debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.logging.log4j.Logger的用法示例。


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

示例1: buildCredentials

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
public static AWSCredentialsProvider buildCredentials(Logger logger, DeprecationLogger deprecationLogger,
                                                      Settings settings, Settings repositorySettings, String clientName) {
    try (SecureString key = getConfigValue(repositorySettings, settings, clientName, S3Repository.ACCESS_KEY_SETTING,
                                           S3Repository.Repository.KEY_SETTING, S3Repository.Repositories.KEY_SETTING);
         SecureString secret = getConfigValue(repositorySettings, settings, clientName, S3Repository.SECRET_KEY_SETTING,
                                              S3Repository.Repository.SECRET_SETTING, S3Repository.Repositories.SECRET_SETTING)) {

        if (key.length() == 0 && secret.length() == 0) {
            logger.debug("Using instance profile credentials");
            return new PrivilegedInstanceProfileCredentialsProvider();
        } else {
            logger.debug("Using basic key/secret credentials");
            return new StaticCredentialsProvider(new BasicAWSCredentials(key.toString(), secret.toString()));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:InternalAwsS3Service.java

示例2: publish

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
@Override
public void publish(LogRecord record) {
    Logger logger = getLogger(record.getLoggerName());
    Throwable exception = record.getThrown();
    Level level = record.getLevel();
    String message = getFormatter().formatMessage(record);

    if (level == Level.SEVERE) {
        logger.error(message, exception);
    } else if (level == Level.WARNING) {
        logger.warn(message, exception);
    } else if (level == Level.INFO) {
        logger.info(message, exception);
    } else if (level == Level.CONFIG) {
        logger.debug(message, exception);
    } else {
        logger.trace(message, exception);
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:20,代码来源:ForwardLogHandler.java

示例3: writeObjectToServletOutputStream

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
/**
 * Appends the string form of the given JSON object to the body of the given HTTP response using the UTF-8
 * charset.
 *
 * @param obj the object to append
 * @param response the http response to which's body the object should be appended
 * @throws IOException if there is an error appending the object.
 */
default void writeObjectToServletOutputStream(JSONObject obj, HttpServletResponse response) throws IOException
{
    Logger logger = LogManager.getLogger(JsonResponseServlet.class.getName());
    logger.debug("entering");

    String objAsString = obj.toString(2);
    logger.trace("objAsString=" + objAsString);
    ByteBuffer byteBuffer = UTF_8.encode(objAsString);
    byte[] responseBodyBytes=new byte[byteBuffer.limit()];
    byteBuffer.get(responseBodyBytes);

    response.getOutputStream().write(responseBodyBytes);

    logger.debug("exiting");
}
 
开发者ID:capergroup,项目名称:bayou,代码行数:24,代码来源:JsonResponseServlet.java

示例4: shouldIgnoreOrRejectNewClusterState

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
/**
 * In the case we follow an elected master the new cluster state needs to have the same elected master and
 * the new cluster state version needs to be equal or higher than our cluster state version.
 * If the first condition fails we reject the cluster state and throw an error.
 * If the second condition fails we ignore the cluster state.
 */
public static boolean shouldIgnoreOrRejectNewClusterState(Logger logger, ClusterState currentState, ClusterState newClusterState) {
    validateStateIsFromCurrentMaster(logger, currentState.nodes(), newClusterState);

    // reject cluster states that are not new from the same master
    if (currentState.supersedes(newClusterState) ||
            (newClusterState.nodes().getMasterNodeId().equals(currentState.nodes().getMasterNodeId()) && currentState.version() == newClusterState.version())) {
        // if the new state has a smaller version, and it has the same master node, then no need to process it
        logger.debug("received a cluster state that is not newer than the current one, ignoring (received {}, current {})", newClusterState.version(), currentState.version());
        return true;
    }

    // reject older cluster states if we are following a master
    if (currentState.nodes().getMasterNodeId() != null && newClusterState.version() < currentState.version()) {
        logger.debug("received a cluster state that has a lower version than the current one, ignoring (received {}, current {})", newClusterState.version(), currentState.version());
        return true;
    }
    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ZenDiscovery.java

示例5: filterPingResponses

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
static List<ZenPing.PingResponse> filterPingResponses(List<ZenPing.PingResponse> fullPingResponses, boolean masterElectionIgnoreNonMasters, Logger logger) {
    List<ZenPing.PingResponse> pingResponses;
    if (masterElectionIgnoreNonMasters) {
        pingResponses = fullPingResponses.stream().filter(ping -> ping.node().isMasterNode()).collect(Collectors.toList());
    } else {
        pingResponses = fullPingResponses;
    }

    if (logger.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        if (pingResponses.isEmpty()) {
            sb.append(" {none}");
        } else {
            for (ZenPing.PingResponse pingResponse : pingResponses) {
                sb.append("\n\t--> ").append(pingResponse);
            }
        }
        logger.debug("filtered ping responses: (ignore_non_masters [{}]){}", masterElectionIgnoreNonMasters, sb);
    }
    return pingResponses;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:ZenDiscovery.java

示例6: createPerformanceLogger

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
@Override
protected PerformanceLogger createPerformanceLogger() throws IOException {
  final Logger logger = createLogger();

  final PerformanceLogger perfLogger = new PerformanceLogger() {
    @Override
    public void log(String message) {
      logger.debug(message);
    }

    @Override
    public boolean isEnabled() {
      return logger.isEnabled(Level.DEBUG);
    }
  };

  return perfLogger;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:LogWriterLoggerDisabledPerformanceTest.java

示例7: test03

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
@Test
    public void test03() {
//        Logger logger = LogManager.getFormatterLogger();
        Logger logger = LogManager.getLogger();

        String name = "李志伟";
        Date birthday = new Date();

        logger.debug("用户名称:[{}], 日期:[{}]", name, birthday);
        logger.info("用户名称:[{}], 日期:[{}]", name, birthday);
        logger.warn("用户名称:[{}], 日期:[{}]", name, birthday);
        logger.error("用户名称:[{}], 日期:[{}]", name, birthday);
        logger.fatal("用户名称:[{}], 日期:[{}]", name, birthday);
        logger.error("异常信息提示", new RuntimeException("异常信息"));

        LogManager.shutdown();
    }
 
开发者ID:Lzw2016,项目名称:log4j2-learn,代码行数:18,代码来源:LogTest.java

示例8: findEndpoint

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
/** Returns the endpoint the client should use, based on the available endpoint settings found. */
static String findEndpoint(Logger logger, Settings repositorySettings, Settings settings, String clientName) {
    String endpoint = getConfigValue(repositorySettings, settings, clientName, S3Repository.ENDPOINT_SETTING,
                                     S3Repository.Repository.ENDPOINT_SETTING, S3Repository.Repositories.ENDPOINT_SETTING);
    if (Strings.isNullOrEmpty(endpoint)) {
        // No region has been set so we will use the default endpoint
        if (CLOUD_S3.ENDPOINT_SETTING.exists(settings)) {
            endpoint = CLOUD_S3.ENDPOINT_SETTING.get(settings);
            logger.debug("using explicit s3 endpoint [{}]", endpoint);
        }
    } else {
        logger.debug("using repository level endpoint [{}]", endpoint);
    }

    return endpoint;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:InternalAwsS3Service.java

示例9: logEventShouldMatchCustomConfig

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
@Test
public void logEventShouldMatchCustomConfig() throws Exception {
  String logLogger = getClass().getName();
  Level logLevel = Level.DEBUG;
  String logMessage = "this is a log statement";

  Logger logger = LogService.getLogger();
  logger.debug(logMessage);

  BasicAppender appender = BasicAppender.getInstance();
  assertThat(appender).isNotNull();
  assertThat(appender.events()).hasSize(1);

  LogEvent event = appender.events().get(0);
  assertThat(event.getLoggerName()).isEqualTo(logLogger);
  assertThat(event.getLevel()).isEqualTo(logLevel);
  assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);

  assertThat(systemOutRule.getLog()).contains(logLevel.name());
  assertThat(systemOutRule.getLog()).contains(logMessage);
  assertThat(systemOutRule.getLog()).contains(CONFIG_LAYOUT_PREFIX);
  assertThat(systemOutRule.getLog()).matches(defineLogStatementRegex(logLevel, logMessage));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:CustomConfigWithLogServiceIntegrationTest.java

示例10: test02

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
@Test
public void test02() {
    Logger logger = LogManager.getLogger(LogTest.class);

    String name = "李志伟";
    Date birthday = new Date();

    logger.debug("用户名称:[{}], 日期:[{}]", name, birthday);
    logger.debug("用户名称:[%s], 日期:[%s]", name, birthday);

    logger.printf(Level.INFO, "用户名称:[%s], 日期:[%s]", name, birthday);
    logger.printf(Level.INFO, "用户名称:[%1$s], 日期:[%2$tY-%2$tm-%2$te]", name, birthday);
    logger.printf(Level.INFO, "Integer.MAX_VALUE = [%,d]", Integer.MAX_VALUE);
    logger.printf(Level.INFO, "Long.MAX_VALUE = [%,d]", Long.MAX_VALUE);

    LogManager.shutdown();
}
 
开发者ID:Lzw2016,项目名称:log4j2-learn,代码行数:18,代码来源:LogTest.java

示例11: test04

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
@Test
public void test04() {
    Logger logger = LogManager.getLogger();
    String name = "李志伟";
    Date birthday = new Date();
    for (int i = 0; i < 10000; i++) {
        logger.debug("次数[{}] 用户名称:[{}], 日期:[{}]", i, name, birthday);
        logger.info("次数[{}] 用户名称:[{}], 日期:[{}]", i, name, birthday);
        logger.warn("次数[{}] 用户名称:[{}], 日期:[{}]", i, name, birthday);
        logger.error("次数[{}] 用户名称:[{}], 日期:[{}]", i, name, birthday);
        logger.fatal("次数[{}] 用户名称:[{}], 日期:[{}]", i, name, birthday);
    }
    LogManager.shutdown();
}
 
开发者ID:Lzw2016,项目名称:log4j2-learn,代码行数:15,代码来源:LogTest.java

示例12: testLogs

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
/**
 * @author wasiq.bhamla
 * @since 17-Jun-2017 6:18:03 PM
 */
@Test
public void testLogs () {
	final Logger log = LogManager.getLogger (TestLogging.class);
	log.info ("Testing info...");
	log.warn ("Testing warn...");
	log.error ("Testing error...");
	log.debug ("Testing debug...");
	log.trace ("Testing trace...");
	log.fatal ("Testing fatal...");
}
 
开发者ID:WasiqB,项目名称:coteafs-logger,代码行数:15,代码来源:TestLogging.java

示例13: checkJarHell

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
/**
 * Checks the current classpath for duplicate classes
 * @throws IllegalStateException if jar hell was found
 */
public static void checkJarHell() throws IOException, URISyntaxException {
    ClassLoader loader = JarHell.class.getClassLoader();
    Logger logger = Loggers.getLogger(JarHell.class);
    if (logger.isDebugEnabled()) {
        logger.debug("java.class.path: {}", System.getProperty("java.class.path"));
        logger.debug("sun.boot.class.path: {}", System.getProperty("sun.boot.class.path"));
        if (loader instanceof URLClassLoader ) {
            logger.debug("classloader urls: {}", Arrays.toString(((URLClassLoader)loader).getURLs()));
         }
    }
    checkJarHell(parseClassPath());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:JarHell.java

示例14: debug

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
public static void debug(Class<?> clazz, String msg, Throwable t) {

		final Logger logger = LogManager.getLogger(clazz);
		if (logger.isDebugEnabled()) {
			logger.debug(msg, t);
		}
	}
 
开发者ID:EonTechnology,项目名称:server,代码行数:8,代码来源:Loggers.java

示例15: test01

import org.apache.logging.log4j.Logger; //导入方法依赖的package包/类
@Test
public void test01() {
    Logger logger = LogManager.getFormatterLogger(LogTest.class);

    String name = "李志伟";
    Date birthday = new Date();

    logger.debug("用户名称:[{}], 日期:[{}]", name, birthday);
    logger.debug("用户名称:[%s], 日期:[%s]", name, birthday);
    logger.debug("用户名称:[%1$s], 日期:[%2$tY-%2$tm-%2$te]", name, birthday);
    logger.debug("Integer.MAX_VALUE = [%,d]", Integer.MAX_VALUE);
    logger.debug("Long.MAX_VALUE = [%,d]", Long.MAX_VALUE);

    LogManager.shutdown();
}
 
开发者ID:Lzw2016,项目名称:log4j2-learn,代码行数:16,代码来源:LogTest.java


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