本文整理汇总了Java中org.slf4j.LoggerFactory类的典型用法代码示例。如果您正苦于以下问题:Java LoggerFactory类的具体用法?Java LoggerFactory怎么用?Java LoggerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoggerFactory类属于org.slf4j包,在下文中一共展示了LoggerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.slf4j.LoggerFactory; //导入依赖的package包/类
/**
*
* @param args
*/
public static void main(String[] args) {
Logger log = LoggerFactory.getLogger(AppDemo.class);
Initializer.getToolBox()
.getEventBus()
.toObserverable()
.subscribe(e -> log.debug(e.toString()));
App.main(args);
ObservableList<Annotation> annotations = Initializer.getToolBox()
.getData()
.getAnnotations();
annotations.addListener((InvalidationListener) observable ->
log.debug("Annotation count: " + annotations.size()));
}
示例2: execNextMethod
import org.slf4j.LoggerFactory; //导入依赖的package包/类
private void execNextMethod(Scope scope, Object instance, List<MyMethod> methods, ProcessingCompleteCallback callback, List<Throwable> failures) {
if (methods.isEmpty()) {
LoggerFactory.getLogger(instance.getClass()).debug("{}[email protected] complete", instance.getClass().getSimpleName());
callback.onComplete(scope, instance, failures);
} else {
MyMethod method = methods.remove(0);
method.handler.post(() -> {
LoggerFactory.getLogger(instance.getClass()).debug("{}.{}()", instance.getClass().getSimpleName(), method.method.getName());
try {
method.method.invoke(instance);
} catch (Throwable t) {
LoggerFactory.getLogger(instance.getClass()).error("{}.{}() -> {}", instance.getClass().getSimpleName(), method.method.getName(), t);
failures.add(t);
}
execNextMethod(scope, instance, methods, callback, failures);
});
}
}
示例3: saveStackState
import org.slf4j.LoggerFactory; //导入依赖的package包/类
/**
* Saves the current stack state into the given bundle by using the serializer in {@link #getInstanceStateSerializer()}
*
* @param outState the target
*/
protected void saveStackState(Bundle outState) {
NavigationBuilder nb = getNavigation();
if (nb instanceof Navigation) {
//create a defensive copy into a serializable list
ArrayList<Request> tmp = new ArrayList<>(((Navigation) nb).getStack());
try {
//serialize simply into a byte array
ByteArrayOutputStream bout = new ByteArrayOutputStream();
getInstanceStateSerializer().serialize(tmp, bout);
outState.putByteArray(HC_NAVIGATION_STACK, bout.toByteArray());
} catch (IOException e) {
//clean it out, in case of programming error
outState.putByteArray(HC_NAVIGATION_STACK, null);
LoggerFactory.getLogger(getClass()).warn("onSaveInstanceState: the navigation stack contains a value which is not serializable by {}. Reason:", getInstanceStateSerializer(), e);
}
} else {
//clean it out, if no navigation is available
outState.putByteArray(HC_NAVIGATION_STACK, null);
LoggerFactory.getLogger(getClass()).warn("onSaveInstanceState: getNavigation() does not provide a Navigation instance");
}
}
示例4: main
import org.slf4j.LoggerFactory; //导入依赖的package包/类
/**
* メインメソッド
*
* @param args 読み込むプロパティファイルのファイルパス
*/
public static void main(final String... args) {
((Logger) LoggerFactory.getLogger("jp.co.future.uroborosql")).setLevel(Level.DEBUG);
String propFile = "repl.properties";
if (args.length != 0) {
propFile = args[0];
}
Path path = Paths.get(propFile);
if (!Files.exists(path)) {
throw new IllegalArgumentException("properties could not found.");
}
try {
SqlREPL repl = new SqlREPL(path);
repl.execute();
} catch (Exception ex) {
throw new IllegalStateException("Failed to REPL.", ex);
}
}
示例5: testBuildShaImage
import org.slf4j.LoggerFactory; //导入依赖的package包/类
@Test
public void testBuildShaImage() throws Exception {
assumeTrue(DockerTestUtils.isDockerAvailable());
//Create Dockerfile and the corresponding Binary file
shaDigest = buildSHADockerfile();
init();
TransformationContext ctx = mock(TransformationContext.class);
when(ctx.getPluginFileAccess()).thenReturn(access);
when(ctx.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("Mock Logger"));
imageBuilder = instantiateImageBuilder(ctx);
logger.info("Building Image");
imageBuilder.buildImage();
logger.info("Storing Image");
imageBuilder.storeImage();
validate(imageBuilder.getTag());
}
示例6: configureSagaManagers
import org.slf4j.LoggerFactory; //导入依赖的package包/类
protected Configurer configureSagaManagers(Configurer configurer) {
Configuration configuration = ReflectionUtils.getField("config", configurer);
configuration.getModules().forEach(m -> {
if (m instanceof SagaConfiguration) {
SagaConfiguration sagaConfig = (SagaConfiguration) m;
Component<EventProcessor> processorComponent = ReflectionUtils.getField("processor", sagaConfig);
String name = ReflectionUtils.getField("name", processorComponent);
processorComponent.update(c -> {
String processorName = format("%s/%s", applicationProperties.getApplicationName(), name);
Logger logger = LoggerFactory.getLogger(processorName);
return new FluxCapacitorEventProcessor(
processorName, sagaConfig.getSagaManager(),
RollbackConfigurationType.ANY_THROWABLE,
errorContext -> logger.error("Failed to handle events on saga", errorContext.error()),
c.messageMonitor(FluxCapacitorEventProcessor.class, processorName), getEventConsumerService(),
c.getComponent(AxonMessageSerializer.class), 1);
});
}
});
return configurer;
}
开发者ID:flux-capacitor-io,项目名称:flux-capacitor-client,代码行数:22,代码来源:AbstractFluxCapacitorConfiguration.java
示例7: init
import org.slf4j.LoggerFactory; //导入依赖的package包/类
@PostConstruct
public void init() {
log.debug("Registering JVM gauges");
metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
log.debug("Initializing Metrics JMX reporting");
JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
jmxReporter.start();
}
if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
log.info("Initializing Metrics Log reporting");
final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
.outputTo(LoggerFactory.getLogger("metrics"))
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
}
}
示例8: main
import org.slf4j.LoggerFactory; //导入依赖的package包/类
public static void main(String[] args) {
/**
* 1.测试{@linkplain cn.xishan.oftenporter.porter.core.annotation.Mixin},自己混入自己
*/
final Logger logger = LoggerFactory.getLogger(MainMixinLoop1.class);
LocalMain localMain = new LocalMain(true, new PName("P1"), "utf-8");
// 进行配置
PorterConf conf = localMain.newPorterConf();
conf.setContextName("MainMixinLoop1");
conf.getSeekPackages().addClassPorter(RootPorter.class);
localMain.startOne(conf);
logger.debug("****************************************************");
logger.debug("****************************************************");
localMain.destroyAll();
}
示例9: onGuildLeave
import org.slf4j.LoggerFactory; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent event)
{
Guild guild = event.getGuild();
User owner = guild.getOwner().getUser();
LoggerFactory.getLogger("Logging").info("[GUILD LEFT]: "+guild.getName()+" (ID: "+guild.getId()+")\n");
long botCount = guild.getMembers().stream().map(m -> m.getUser()).filter(u -> u.isBot()).count();
long userCount = guild.getMembers().stream().map(m -> m.getUser()).filter(u -> !(u.isBot())).count();
long totalCount = guild.getMembers().size();
TextChannel tc = event.getJDA().getTextChannelById(config.getBotlogChannelId());
String reason = getReason(guild);
if(config.isBotlogEnabled() && !(tc==null) && tc.canTalk())
{
StringBuilder builder = new StringBuilder().append(":outbox_tray: `[Left Guild]:` "+guild.getName()+" (ID: "+guild.getId()+")\n" +
"`[Owner]:` **"+owner.getName()+"**#**"+owner.getDiscriminator()+"** (ID: "+owner.getId()+"\n" +
"`[Members]:` Humans: **"+userCount+"** Bots: **"+botCount+"** Total Count: **"+totalCount+"**\n");
if(!(reason==null))
builder.append("`[Reason]:` "+reason);
tc.sendMessage(builder.toString()).queue();
}
}
示例10: redirectLogger
import org.slf4j.LoggerFactory; //导入依赖的package包/类
private static boolean redirectLogger(Logger logger, boolean isVerbose) {
if (logger instanceof ch.qos.logback.classic.Logger) {
try {
// rewrite console logger to stderr and set log level based on verbosity
// keep logger implementation details out of AvroCountTool
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(isVerbose ? ch.qos.logback.classic.Level.DEBUG : ch.qos.logback.classic.Level.ERROR);
ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender = root.getAppender("console");
((ch.qos.logback.core.ConsoleAppender) appender).setTarget(ch.qos.logback.core.joran.spi.ConsoleTarget.SystemErr.getName());
appender.start();
return true;
} catch (Exception e) {
LOGGER.warn("An unexpected error occurred while trying to redirect logger", e);
}
}
return false;
}
示例11: buildSchema
import org.slf4j.LoggerFactory; //导入依赖的package包/类
/**
* Builds a schema from the given schema sources.
*
* @param lang schema language, must not be null
* @param schemaSources schema sources, must not be null
*
* @return the constructed schema
*
* @throws SAXException thrown if there is a problem converting the schema sources in to a schema
*/
protected static Schema buildSchema(SchemaLanguage lang, Source[] schemaSources) throws SAXException {
if(lang == null){
throw new IllegalArgumentException("Schema language may not be null");
}
if(schemaSources == null){
throw new IllegalArgumentException("Schema sources may not be null");
}
SchemaFactory schemaFactory;
if (lang == SchemaLanguage.XML) {
schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
} else {
schemaFactory = SchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);
}
schemaFactory.setErrorHandler(new LoggingErrorHandler(LoggerFactory.getLogger(SchemaBuilder.class)));
return schemaFactory.newSchema(schemaSources);
}
示例12: readGeometry
import org.slf4j.LoggerFactory; //导入依赖的package包/类
private static Geometry readGeometry(List<Integer> geomCmds,
VectorTile.Tile.GeomType geomType,
GeometryFactory geomFactory,
Vec2d cursor,
RingClassifier ringClassifier) {
Geometry result = null;
switch (geomType) {
case POINT:
result = readPoints(geomFactory, geomCmds, cursor);
break;
case LINESTRING:
result = readLines(geomFactory, geomCmds, cursor);
break;
case POLYGON:
result = readPolys(geomFactory, geomCmds, cursor, ringClassifier);
break;
default:
LoggerFactory.getLogger(MvtReader.class)
.error("readGeometry(): Unhandled geometry type [{}]", geomType);
}
return result;
}
示例13: parseCsv
import org.slf4j.LoggerFactory; //导入依赖的package包/类
static Map<Integer, List<TimeSeries>> parseCsv(BufferedReader reader, char separator) {
Objects.requireNonNull(reader);
Stopwatch stopwatch = Stopwatch.createStarted();
Map<Integer, List<TimeSeries>> timeSeriesPerVersion = new HashMap<>();
String separatorStr = Character.toString(separator);
try {
CsvParsingContext context = readCsvHeader(reader, separatorStr);
readCsvValues(reader, separatorStr, context, timeSeriesPerVersion);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
LoggerFactory.getLogger(TimeSeries.class)
.info("{} time series loaded from CSV in {} ms",
timeSeriesPerVersion.entrySet().stream().mapToInt(e -> e.getValue().size()).sum(),
stopwatch.elapsed(TimeUnit.MILLISECONDS));
return timeSeriesPerVersion;
}
示例14: main
import org.slf4j.LoggerFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
GrainLog grainLog = new GrainLog(LoggerFactory.getLogger("minaLog"));
GrainLog grainLog1 = new GrainLog(LoggerFactory.getLogger("msgLog"));
// 初始化消息
MsgManager.init(true, grainLog1);
// 映射操作码解析类
TcpManager.addMapping(TestTCode.TESTC, TestC.class);
TcpManager.addMapping(TestTCode.TESTS, TestS.class);
// 注册tcp回调函数
TestTcpServiceS testTcpServiceS = new TestTcpServiceS();
TcpManager.addTcpListener(testTcpServiceS);
// 创建TCP服务器
MinaServer.init("0.0.0.0", 7005, MinaServerHandler.class, true, grainLog);
}
示例15: ObjectExtractorStreamEngine
import org.slf4j.LoggerFactory; //导入依赖的package包/类
protected ObjectExtractorStreamEngine(PDPage page) {
super(page);
this.log = LoggerFactory.getLogger(ObjectExtractorStreamEngine.class);
this.rulings = new ArrayList<>();
this.pageTransform = null;
// calculate page transform
PDRectangle cb = this.getPage().getCropBox();
int rotation = this.getPage().getRotation();
this.pageTransform = new AffineTransform();
if (Math.abs(rotation) == 90 || Math.abs(rotation) == 270) {
this.pageTransform = AffineTransform.getRotateInstance(rotation * (Math.PI / 180.0), 0, 0);
this.pageTransform.concatenate(AffineTransform.getScaleInstance(1, -1));
} else {
this.pageTransform.concatenate(AffineTransform.getTranslateInstance(0, cb.getHeight()));
this.pageTransform.concatenate(AffineTransform.getScaleInstance(1, -1));
}
this.pageTransform.translate(-cb.getLowerLeftX(), -cb.getLowerLeftY());
}