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


Java LogManager.getLogger方法代码示例

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


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

示例1: test

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
@Test
public void test() {
    {
        Logger logger = LogManager.getLogger("test.logger");
        logger.error("This is an error!");
        logger.error("This is another error!");
        logger.error("This is a third error!");
    }

    assertThat(collector.getLogs()).hasSize(3)
            .contains("This is an error!", "This is another error!", "This is a third error!");

    List<LogEvent> rawLogs = (List<LogEvent>) collector.getRawLogs();
    assertThat(rawLogs).hasSize(3);

    assertTrue(rawLogs.stream().allMatch(l -> l.getLevel() == Level.ERROR));
}
 
开发者ID:haasted,项目名称:TestLogCollectors,代码行数:18,代码来源:Log4j2Test.java

示例2: init

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
public void init() {
    if (getLogger() != null && !enabled)
        return;
    pluginManifest = getGson().fromJson(new InputStreamReader(getClass().getResourceAsStream("/plugin.json")), PluginManifest.class);
    this.name = this.pluginManifest.getName();
    File plDir = new File(Minecraft.getMinecraft().mcDataDir, "plugins");
    this.dataDir = new File(plDir, this.name);
    this.dataDir.mkdirs();
    this.loadConfig();
    this.uuid = this.pluginConfig.getPluginUUID();
    this.logger = LogManager.getLogger(getName());
    for (String p : pluginManifest.getPermissions()) {
        Permission permission = Permissions.get(p);
        if (permission != null)
            this.permissions.add(permission);
        else
            getLogger().error("Wrong permission: " + p);
    }
}
 
开发者ID:WurstSDK-Team,项目名称:WurstSDK,代码行数:20,代码来源:JavaPlugin.java

示例3: Randores

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
public Randores() {
    Randores.INSTANCE = this;
    this.logger = LogManager.getLogger("Randores");

    info("Constructing Randores mod...");

    Randores.TAB_CRAFTING = new SimpleTab("randores_crafting", () -> new ItemStack(CraftingBlocks.tableItem));
    Randores.TAB_ARMOR = new RandoresArmorTab();

    RandoresJLSC.registerDefaults();

    info("Loading configuration...");

    this.confDir = new File("config", "randores");
    this.loadConfig();

    info("Finished loading config.",
            "Registering listeners...");
    MinecraftForge.EVENT_BUS.register(new RandoresJLSC());

    MinecraftForge.EVENT_BUS.register(new RandoresRegistryListener());
    MinecraftForge.EVENT_BUS.register(new RandoresPlayerListener());
    MinecraftForge.EVENT_BUS.register(new RandoresWorldListener());
    MinecraftForge.EVENT_BUS.register(new EmpoweredArmorListener());
    MinecraftForge.EVENT_BUS.register(new LivingHurtListener());
    MinecraftForge.EVENT_BUS.register(new ScheduleListener());
    MinecraftForge.EVENT_BUS.register(new RandoresMobEquip());
    MinecraftForge.EVENT_BUS.register(new RandoresStarterKit());
    MinecraftForge.EVENT_BUS.register(new RandoresLoot());

    if (FMLCommonHandler.instance().getSide().isClient()) {
        MinecraftForge.EVENT_BUS.register(new RandoresClientListener());
    }

    info("Registered listeners.");
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:37,代码来源:Randores.java

示例4: test03

import org.apache.logging.log4j.LogManager; //导入方法依赖的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

示例5: Log4j2LoggerAdapter

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
public Log4j2LoggerAdapter() {
	try {
		org.apache.logging.log4j.Logger logger = LogManager.getLogger();
		if (logger != null) {
			Map<String, Appender> appenderMap = ((org.apache.logging.log4j.core.Logger) logger).getAppenders();
			for (Map.Entry<String, Appender> entry : appenderMap.entrySet()) {
				if (entry.getValue() instanceof FileAppender) {
					String filename = ((FileAppender) entry.getValue()).getFileName();
					file = new File(filename);
					break;
				}
			}
		}
	} catch (Throwable t) {
	}
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:17,代码来源:Log4j2LoggerAdapter.java

示例6: SocketSession

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
public SocketSession() {
  webSocketFactory = new WebSocketFactory()
      .setConnectionTimeout(SocketClient.CONNECTION_TIMEOUT)
      .setSSLContext(new SslOverTlsContextFactory().getSslContext());
  logger = LogManager.getLogger(getClass());
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:7,代码来源:SocketSession.java

示例7: trace

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

		final Logger logger = LogManager.getLogger(clazz);
		if (logger.isTraceEnabled()) {
			logger.trace(msg, args);
		}

	}
 
开发者ID:EonTechnology,项目名称:server,代码行数:9,代码来源:Loggers.java

示例8: preInit

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    logger = LogManager.getLogger("lagssie");
    config = new Configuration(event.getSuggestedConfigurationFile());

    intervalClient = config.getFloat("intervalClient", "general", 0.25f, 0f, 1000.0f, "If the client is stuck longer than this amount of time (in seconds), dump a stacktrace of what it is doing. Set to 0 to disable.");
    intervalServer = config.getFloat("intervalServer", "general", 0.25f, 0f, 1000.0f, "If the server is stuck longer than this amount of time (in seconds), dump a stacktrace of what it is doing. Set to 0 to disable.");

    config.save();
}
 
开发者ID:asiekierka,项目名称:LagssieMC,代码行数:11,代码来源:Lagssie.java

示例9: test04

import org.apache.logging.log4j.LogManager; //导入方法依赖的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

示例10: debug

import org.apache.logging.log4j.LogManager; //导入方法依赖的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

示例11: createLogger

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
protected Logger createLogger() throws IOException {
  // create configuration with log-file and log-level
  this.configDirectory = new File(getUniqueName());
  this.configDirectory.mkdir();
  assertTrue(this.configDirectory.isDirectory() && this.configDirectory.canWrite());

  // copy the log4j2-test.xml to the configDirectory
  // final URL srcURL =
  // getClass().getResource("/org/apache/geode/internal/logging/log4j/log4j2-test.xml");
  final URL srcURL = getClass().getResource("log4j2-test.xml");
  final File src = new File(srcURL.getFile());
  FileUtils.copyFileToDirectory(src, this.configDirectory);
  this.config = new File(this.configDirectory, "log4j2-test.xml");
  assertTrue(this.config.exists());

  this.logFile = new File(this.configDirectory, DistributionConfig.GEMFIRE_PREFIX + "log");
  final String logFilePath = IOUtils.tryGetCanonicalPathElseGetAbsolutePath(logFile);
  final String logFileName = FileUtil.stripOffExtension(logFilePath);
  setPropertySubstitutionValues(logFileName, DEFAULT_LOG_FILE_SIZE_LIMIT,
      DEFAULT_LOG_FILE_COUNT_LIMIT);

  final String configPath =
      "file://" + IOUtils.tryGetCanonicalPathElseGetAbsolutePath(this.config);
  System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configPath);

  final Logger logger = LogManager.getLogger();
  return logger;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:29,代码来源:Log4J2PerformanceTest.java

示例12: Logger

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
public Logger(Class clazz) {
    logger = LogManager.getLogger(clazz.getSimpleName());
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:4,代码来源:Logger.java

示例13: Log4jLogger

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
Log4jLogger(String name) {
	log = LogManager.getLogger(name);
}
 
开发者ID:battlesteed,项目名称:hibernateMaster,代码行数:4,代码来源:Log4jLoggerFactory.java

示例14: info

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
public static void info(Class<?> clazz, String message) {

		final Logger logger = LogManager.getLogger(clazz);
		if (logger.isInfoEnabled())
			logger.info(message);
	}
 
开发者ID:EonTechnology,项目名称:server,代码行数:7,代码来源:Loggers.java

示例15: AbstractComponent

import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
public AbstractComponent(Settings settings, Class customClass) {
    this.logger = LogManager.getLogger(customClass);
    this.deprecationLogger = new DeprecationLogger(logger);
    this.settings = settings;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:AbstractComponent.java


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