本文整理汇总了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));
}
示例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);
}
}
示例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.");
}
示例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();
}
示例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) {
}
}
示例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());
}
示例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);
}
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}
示例12: Logger
import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
public Logger(Class clazz) {
logger = LogManager.getLogger(clazz.getSimpleName());
}
示例13: Log4jLogger
import org.apache.logging.log4j.LogManager; //导入方法依赖的package包/类
Log4jLogger(String name) {
log = LogManager.getLogger(name);
}
示例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);
}
示例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;
}