本文整理汇总了Java中org.slf4j.LoggerFactory.getILoggerFactory方法的典型用法代码示例。如果您正苦于以下问题:Java LoggerFactory.getILoggerFactory方法的具体用法?Java LoggerFactory.getILoggerFactory怎么用?Java LoggerFactory.getILoggerFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.slf4j.LoggerFactory
的用法示例。
在下文中一共展示了LoggerFactory.getILoggerFactory方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeLogback
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@PostConstruct
public void initializeLogback() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
InputStream is = InitLogback.class.getClassLoader().getResourceAsStream("tasfe-logback.xml");
if (is == null)
return;
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
try {
configurator.doConfigure(is);
} catch (JoranException e) {
e.printStackTrace();
}
}
示例2: getList
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@GetMapping("/logs")
@Timed
public List<LoggerVM> getList() {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
return context.getLoggerList()
.stream()
.map(LoggerVM::new)
.collect(Collectors.toList());
}
示例3: changeLevel
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@PutMapping("/logs")
@ResponseStatus(HttpStatus.NO_CONTENT)
@Timed
public void changeLevel(@RequestBody LoggerVM jsonLogger) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
}
示例4: connect
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
private static void connect(String URI){
//Change MongoDB's logger settings
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
rootLogger = loggerContext.getLogger("org.mongodb.driver");
rootLogger.setLevel(Level.INFO);
//Setup Connection
MongoClientURI connectionString = new MongoClientURI(URI);
MongoClient mongoClient = new MongoClient(connectionString);
MongoDatabase database = mongoClient.getDatabase("media_information_service_db");
collection = database.getCollection("messages");
}
示例5: execute
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
if (clientRegistry.getClients().isEmpty()) {
log.warn("No bots to track data for");
}
for (Map.Entry<Bot, IDiscordClient> entry : clientRegistry.getClients().entrySet()) {
IDiscordClient client = entry.getValue();
if (client.isReady()) {
String botTag = "bot:" + entry.getKey().getName();
for (IShard shard : client.getShards()) {
String shardTag = "shard:" + shard.getInfo()[0];
long millis = shard.getResponseTime();
metricRegistry.timer("discord.ws.response[" + botTag + "," + shardTag + "]")
.update(millis, TimeUnit.MILLISECONDS);
}
for (IGuild guild : client.getGuilds()) {
String guildTag = "guild:" + guild.getStringID();
long online = guild.getUsers().stream()
.filter(user -> user.getPresence().getStatus() == StatusType.ONLINE)
.count();
long connected = guild.getUsers().stream()
.filter(user -> user.getPresence().getStatus() != StatusType.OFFLINE)
.count();
long joined = guild.getUsers().size();
String onlineMetric = "discord.ws.users[" + botTag + "," + guildTag + "," + "status:online]";
String connectedMetric = "discord.ws.users[" + botTag + "," + guildTag + "," + "status:connected]";
String joinedMetric = "discord.ws.users[" + botTag + "," + guildTag + "," + "status:joined]";
metricRegistry.histogram(onlineMetric).update(online);
metricRegistry.histogram(connectedMetric).update(connected);
metricRegistry.histogram(joinedMetric).update(joined);
}
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
loggerContext.getLogger("org.eclipse.jetty.websocket").setLevel(Level.WARN);
loggerContext.getLogger(Discord4J.class).setLevel(Level.DEBUG);
} else {
log.warn("Bot {} is not ready!", entry.getKey().getName());
}
}
}
示例6: init
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@PostConstruct
public void init() {
LOG.info("Send SQL log: " + sendSqllog);
if (!sendSqllog) {
return;
}
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
List<String> loggerNames = Arrays.asList("jp.co.future.uroborosql.AbstractAgent", "jp.co.future.uroborosql.filter.DebugSqlFilter");
context.getLoggerList().stream()
.filter(logger -> loggerNames.contains(logger.getName()))
.forEach(logger -> logger.addAppender(SqlLogAppender.this));
setContext(context);
start();
}
示例7: addSampleLogger
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
/**
* Allow only selected logger to print DEBUG events to STDOUT and FILE.
* Other loggers are allowed to print ERRORS only.
*/
private static void addSampleLogger(final String loggerName) {
if (CUSTOM_FILTER == null) {
CUSTOM_FILTER = new CustomFilter();
final LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
Appender ca = loggerContext.getLogger("ROOT").getAppender("STDOUT");
ca.clearAllFilters();
ca.addFilter(CUSTOM_FILTER);
}
CUSTOM_FILTER.addVisibleLogger(loggerName);
}
示例8: initLogback
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
private static void initLogback() throws JoranException {
String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(rocketmqHome + "/conf/logback_tools.xml");
}
示例9: getList
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@GetMapping("/logs")
public List<LoggerVM> getList() {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
return context.getLoggerList()
.stream()
.map(LoggerVM::new)
.collect(Collectors.toList());
}
示例10: changeLevel
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@PutMapping("/logs")
@Timed
public void changeLevel(@RequestBody LoggerDTO jsonLogger) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
}
示例11: turnOffSentry
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
private void turnOffSentry() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
SentryAppender sentryAppender = (SentryAppender) lc.getLogger(Logger.ROOT_LOGGER_NAME).getAppender("SENTRY");
Sentry.close();
sentryAppender.stop();
}
示例12: testLogstashAppender
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@Test
public void testLogstashAppender() {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
assertThat(context.getLogger("ROOT").getAppender("ASYNC_LOGSTASH")).isInstanceOf(AsyncAppender.class);
}
示例13: testSlf4jFactorySet
import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@Test
public void testSlf4jFactorySet() throws Exception {
ILoggerFactory factory = LoggerFactory.getILoggerFactory();
assertThat(factory).isInstanceOf(Log4jLoggerFactory.class);
}