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


Java LoggerFactory.getLogger方法代码示例

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


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

示例1: outputFile

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
private static void outputFile(List<Resource> resList,
    Properties properties) throws IOException, URISyntaxException {
  //不可以作为class的变量初始化,因为在outputFile前一句log机制才初始化完成的
  //must create org.slf4j.impl.Log4jLoggerAdapter by LoggerExtFactory
  //in order to redefine Log4jLoggerAdapter before other class load Log4jLoggerAdapter
  Logger log = LoggerFactory.getLogger(Log4jUtils.class);

  String content = genFileContext(resList, properties);
  //不打印配置信息,有密钥等敏感信息
  //log.info("Merged log4j:\n{}", content);

  Resource res = resList.get(resList.size() - 1);
  // 不能直接使用res.getFile,因为jar里面的资源,getFile会抛异常
  File file = new File(res.getURL().getPath());
  if (!file.getParentFile().canWrite()) {
    log.error("Can not output {},because can not write to directory of file {}",
        MERGED_FILE,
        res.getURL().getPath());
    return;
  }

  File mergedfile = new File(res.getFile().getParentFile(), MERGED_FILE);
  FileUtils.writeStringToFile(mergedfile, content);
  log.info("Write merged log4j config file to {}", mergedfile.getAbsolutePath());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:Log4jUtils.java

示例2: 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(MainMixinLoop4.class);

    LocalMain localMain = new LocalMain(true, new PName("P1"), "utf-8");

    // 进行配置
    PorterConf conf = localMain.newPorterConf();
    conf.setContextName("MainMixinLoop4");
    conf.getSeekPackages().addClassPorter(Root4Porter.class);
    localMain.startOne(conf);
    logger.debug("****************************************************");


    logger.debug("****************************************************");
    localMain.destroyAll();

}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:21,代码来源:MainMixinLoop4.java

示例3: ping

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
public static boolean ping(int port, final String expectedMsg) {
    boolean beaconExists = false;
    try {
        Socket socket = new Socket("localhost", port);
        final BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        final OutputStream output = socket.getOutputStream();
        output.write("ping\n".getBytes());
        String response = reader.readLine();
        beaconExists = response.equals(expectedMsg);
        socket.close();
    }
    catch (Exception e) {
        Logger log = LoggerFactory.getLogger(ActiveAppPinger.class);
        if (log.isDebugEnabled()) {
            log.debug("Failed to connect to port " + port, e);
        }
    }
    return beaconExists;

}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:21,代码来源:ActiveAppPinger.java

示例4: onCreate

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    StaticLoggerBinder.init(this);
    log = LoggerFactory.getLogger(DbSyncApplication.class);

    log.info("onCreate");

    db1OpenHelper = new Db1OpenHelper(this);
    db1OpenHelper.getReadableDatabase();

    db2OpenHelper = new Db2OpenHelper(this);
    db2OpenHelper.getReadableDatabase();

    db3OpenHelper = new Db3OpenHelper(this);
    db3OpenHelper.getReadableDatabase();

    db4OpenHelper = new Db4OpenHelper(this);
    db4OpenHelper.getReadableDatabase();

    db5OpenHelper = new Db5OpenHelper(this);
    db5OpenHelper.getReadableDatabase();
}
 
开发者ID:claudiodegio,项目名称:dbsync,代码行数:25,代码来源:DbSyncApplication.java

示例5: testWriteXxxxxResult

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@Test
public void testWriteXxxxxResult() throws TechnicalException {
    final OutputConsoleDataProvider outputConsoleDataProvider = new OutputConsoleDataProvider();
    outputConsoleDataProvider.prepare("hello");
    Assert.assertTrue(true);

    Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);

    final TestAppender<ILoggingEvent> appender = new TestAppender<>();
    appender.start();
    logger.addAppender(appender);
    outputConsoleDataProvider.writeFailedResult(1, "UT Failed Message");
    List<ILoggingEvent> log = appender.getLog();
    Assert.assertEquals(Level.ERROR, log.get(0).getLevel());
    Assert.assertTrue(log.get(0).getMessage().toString().endsWith(String.format(Messages.getMessage("OUTPUT_CONSOLE_DATA_PROVIDER_FAILED_AT_LINE"), 1, "UT Failed Message")));

    outputConsoleDataProvider.writeSuccessResult(2);
    log = appender.getLog();
    Assert.assertEquals(Level.INFO, log.get(1).getLevel());
    Assert.assertTrue(log.get(1).getMessage().toString().endsWith(String.format(Messages.getMessage("OUTPUT_CONSOLE_DATA_PROVIDER_SUCCESS_AT_LINE"), 2)));

    outputConsoleDataProvider.writeWarningResult(3, "UT Warning Message");
    log = appender.getLog();
    Assert.assertEquals(Level.WARN, log.get(2).getLevel());
    Assert.assertTrue(log.get(2).getMessage().toString().endsWith(String.format(Messages.getMessage("OUTPUT_CONSOLE_DATA_PROVIDER_WARNING_AT_LINE"), 3, "UT Warning Message")));

    outputConsoleDataProvider.writeDataResult("title", 4, "UT title");
    log = appender.getLog();
    Assert.assertEquals(Level.INFO, log.get(3).getLevel());
    Assert.assertTrue(log.get(3).getMessage().toString().endsWith(String.format(Messages.getMessage("OUTPUT_CONSOLE_DATA_PROVIDER_RESULT_AT_LINE"), 4, "title", "UT title")));
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:32,代码来源:OutputConsoleDataProviderUT.java

示例6: springLogging

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@Bean
@ConditionalOnClass(Logger.class)
public CommonsRequestLoggingFilter springLogging() {
    Logger logger = (Logger) LoggerFactory.getLogger(CommonsRequestLoggingFilter.class);
    logger.setLevel(Level.DEBUG);
    log.info("Http logging enabled {}.", properties);
    return requestLoggingFilter();
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:9,代码来源:HttpLoggingConfig.java

示例7: toStringTestTest

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@Test
public void toStringTestTest() throws Exception {
    Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    LoggerVM vm = new LoggerVM(logger);
    assertTrue(vm.toString().startsWith(LoggerVM.class.getSimpleName()));
    String json = vm.toString().replace(LoggerVM.class.getSimpleName(), "");
    assertTrue(TestUtils.isValid(json));
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:9,代码来源:LoggerVMTest.java

示例8: TextAreaLogAppender

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
public TextAreaLogAppender(TextArea textArea) {
    this.textArea = textArea;
    logger = (Logger) LoggerFactory.getLogger("com.intuit.karate");
    setName("karate-ui");
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    setContext(lc);
    encoder = new PatternLayoutEncoder();
    encoder.setPattern("%d{HH:mm:ss.SSS} %-5level - %msg%n");
    encoder.setContext(context);
    encoder.start();
    start();
    logger.addAppender(this);
    logger.setLevel(Level.DEBUG);
}
 
开发者ID:intuit,项目名称:karate,代码行数:15,代码来源:TextAreaLogAppender.java

示例9: parsed

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@Override
public Ethernet parsed() {
    checkPermission(PACKET_READ);

    try {
        return Ethernet.deserializer().deserialize(pktin.getData(), 0, pktin.getData().length);
    } catch (BufferUnderflowException | NullPointerException |
            DeserializationException e) {
        Logger log = LoggerFactory.getLogger(getClass());
        log.error("packet deserialization problem : {}", e.getMessage());
        return null;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:DefaultOpenFlowPacketContext.java

示例10: reInitLogConfig

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
/**
 * 根据配置文件路径初始化日志配置
 * @param logConfigpath
 */
public static void reInitLogConfig(String logConfigpath)
{
	try {
		 LoggerContext context =(LoggerContext)LogManager.getContext(false);
	     context.setConfigLocation(new File(logConfigpath).toURI());
	     context.reconfigure(); //重新初始化Log4j2的配置上下文
	     Logger log=LoggerFactory.getLogger(Log4jUtil.class);
		 log.info("日志配置重新初始化完成:"+logConfigpath);
	} catch (Exception e) {
		e.printStackTrace();
	}  
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:17,代码来源:Log4jUtil.java

示例11: changeMode

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
public String changeMode(String changingMode) throws IOException, ConsoleException {
    Logger log = LoggerFactory.getLogger(getClass());
    log.debug("mode-change: " + this.currentMode + " to " + changingMode);
    if (MODE_ENABLE.equals(currentMode) && changingMode.startsWith(MODE_CONFIG)) {
        sendln("config");
        currentMode = changingMode;
        return translate(receiveToPrompt());
    } else if (currentMode.startsWith(MODE_CONFIG) && changingMode.startsWith(MODE_ENABLE)) {
        sendln("exit");
        currentMode = changingMode;
        return translate(receiveToPrompt());
    } else {
        return "";
    }
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:16,代码来源:FlashWaveTelnetClient.java

示例12: getLevelTest

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@Test
public void getLevelTest() throws Exception {
    LoggerVM vm = new LoggerVM();
    assertNull(vm.getLevel());

    Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    vm = new LoggerVM(logger);
    assertEquals(Level.ERROR.toString(), vm.getLevel());
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:10,代码来源:LoggerVMTest.java

示例13: ProductServiceImpl

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
@Autowired
public ProductServiceImpl(ProductRepository productRepository, SupplierRepository supplierRepository) {
    this.logger = LoggerFactory.getLogger(this.getClass());
    this.productRepository = productRepository;
    this.supplierRepository = supplierRepository;
}
 
开发者ID:experiment322,项目名称:fullstack-project-backend,代码行数:7,代码来源:ProductServiceImpl.java

示例14: setupLogging

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
protected void setupLogging() {
    addSampleLogger(loggerName);
    logger = LoggerFactory.getLogger(loggerName);
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:5,代码来源:BasicSample.java

示例15: log

import org.slf4j.LoggerFactory; //导入方法依赖的package包/类
private static Logger log() {
    if (logger == null) {
        logger = LoggerFactory.getLogger(Util.class);
    }
    return logger;
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:7,代码来源:Util.java


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