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


Java Logger.info方法代码示例

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


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

示例1: main

import org.apache.log4j.Logger; //导入方法依赖的package包/类
public static void main(String args[])
{
	Logger logger = Logger.getLogger(com.dytech.common.log4j.DailySizeRollingAppender.class);
	do
	{
		logger.info("This is an info statement");
		logger.warn("This is a warning");
		logger.error("This is an error");
		try
		{
			throw new Exception();
		}
		catch( Exception ex )
		{
			logger.fatal("This is fatal", ex);
		}
	}
	while( true );
}
 
开发者ID:equella,项目名称:Equella,代码行数:20,代码来源:DailySizeRollingAppender.java

示例2: testApp

import org.apache.log4j.Logger; //导入方法依赖的package包/类
/**
   * Rigourous Test :-)
   */
  public void testApp()
  {
try {

	Logger logger = Logger.getLogger("Log4jALALogger");

	for (int i = 0; i < 100; i++) {
		HashMap<String, Object> logMessage = new HashMap<String, Object>();
		logMessage.put("id", String.format("log-%d", i));
		logMessage.put("message", String.format("test-%d", i));
		logger.info(logMessage);
	}

	Thread.sleep((long) 20000);
	assertTrue( true );
} catch (InterruptedException e) {
	assertTrue( false );
	e.printStackTrace();
}

  }
 
开发者ID:ptv-logistics,项目名称:Log4jALA,代码行数:25,代码来源:AppTest.java

示例3: redirectToAnotherPage

import org.apache.log4j.Logger; //导入方法依赖的package包/类
@Test
public void redirectToAnotherPage() throws Exception {

    String pageSource = webEngine.getPageSource();
    Logger log = Logger.getLogger(this.getClass());
    log.info("Current page source: " + pageSource);

    UiLink linkOnInitialPage = webEngine.getLink("link2");
    linkOnInitialPage.click();

    // verify we left the initial page
    webEngine.getUtilsElementState(linkOnInitialPage).verifyNotExist();

    // go back to the initial page
    UiLink linkOnNewPage = webEngine.getLink("link");
    linkOnNewPage.click();

    // verify we are back at the initial page
    webEngine.getUtilsElementState(linkOnInitialPage).verifyExist();
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:21,代码来源:Test_Link.java

示例4: main

import org.apache.log4j.Logger; //导入方法依赖的package包/类
public static void main(String[] args) {
	try {

		Logger logger = Logger.getLogger("Log4jALALogger");

		for (int i = 0; i < 100; i++) {
			HashMap<String, Object> logMessage = new HashMap<String, Object>();
			logMessage.put("id", String.format("log-%d", i));
			logMessage.put("message", String.format("test-%d", i));
			logger.info(logMessage);
		}

		Thread.sleep((long) 300000);
	} catch (InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:ptv-logistics,项目名称:Log4jALA,代码行数:19,代码来源:Test.java

示例5: execute

import org.apache.log4j.Logger; //导入方法依赖的package包/类
@Override
public boolean execute(Context javascriptContext, Scriptable scope) throws EngineException {
	if (isEnabled()) {
		if (super.execute(javascriptContext, scope)) {
			Logger log = engine ? Engine.logEngine : Engine.logContext;
			if(level.equals(Level.WARN.toString()) && log.isEnabledFor(Level.WARN))
				log.warn(getEvalString(javascriptContext, scope));
			else if(level.equals(Level.INFO.toString()) && log.isInfoEnabled())
				log.info(getEvalString(javascriptContext, scope));
			else if(level.equals(Level.DEBUG.toString()) && log.isDebugEnabled())
				log.debug(getEvalString(javascriptContext, scope));
			else if(level.equals(Level.TRACE.toString()) && log.isTraceEnabled())
				log.trace(getEvalString(javascriptContext, scope));
			else if(level.equals(Level.ERROR.toString()) && log.isEnabledFor(Level.ERROR))
				log.error(getEvalString(javascriptContext, scope));
			return true;
		}
	}
	return false;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:21,代码来源:LogStatement.java

示例6: GroupResultDiskBuffer

import org.apache.log4j.Logger; //导入方法依赖的package包/类
/**
 * @param pool
 * @param columnCount
 * @param cmp          group by comparator
 * @param packets      packets which already contain sum_function's fieldpacket,
 *                     sum_packets are put in the front
 * @param sumFunctions
 */
public GroupResultDiskBuffer(BufferPool pool, int fieldsCount, RowDataComparator cmp, List<FieldPacket> packets,
                             List<ItemSum> sumFunctions, boolean isAllPushDown, String charset) {
    super(pool, fieldsCount, cmp);
    /*
  store the origin row fields,(already contains the item_sum fields in
  rowpackets we should calculate the item_sums again when next() is
  called!)
 */
    List<Field> fields = HandlerTool.createFields(packets);
    this.sums = new ArrayList<>();
    for (ItemSum sumFunc : sumFunctions) {
        ItemSum sum = (ItemSum) (HandlerTool.createItem(sumFunc, fields, 0, isAllPushDown,
                HandlerType.GROUPBY));
        this.sums.add(sum);
    }
    Logger logger = Logger.getLogger(GroupResultDiskBuffer.class);
    logger.info("prepare_sum_aggregators");
    prepareSumAggregators(this.sums, true);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:28,代码来源:GroupResultDiskBuffer.java

示例7: main

import org.apache.log4j.Logger; //导入方法依赖的package包/类
public static void main(String[] args) {
    Logger LOG = Logger.getLogger(LogFilesStructure.class);
    ApplicationContext ctx = SpringApplication.run(Application.class, args);

    LOG.debug("Spring Boot instantiated beans:");

    String[] beanNames = ctx.getBeanDefinitionNames();

    Arrays.sort(beanNames);
    for (String beanName : beanNames) {
        LOG.debug(beanName);
    }
    LOG.info("\n....................................................." +
            "\n.................Spring boot started................." +
            "\n.....................................................\n");

}
 
开发者ID:asmodeirus,项目名称:BackOffice,代码行数:18,代码来源:Application.java

示例8: main

import org.apache.log4j.Logger; //导入方法依赖的package包/类
public static void main(String args[])
{
	Logger logger = Logger.getLogger(DailySizeRollingAppender.class);
	do
	{
		logger.info("This is an info statement");
		logger.warn("This is a warning");
		logger.error("This is an error");
		try
		{
			throw new Exception();
		}
		catch( Exception ex )
		{
			logger.fatal("This is fatal", ex);
		}
	}
	while( true );
}
 
开发者ID:equella,项目名称:Equella,代码行数:20,代码来源:DailySizeRollingAppender.java

示例9: log

import org.apache.log4j.Logger; //导入方法依赖的package包/类
private void log(LogMessage logMessage, LogLevel level, String loggerName) {
	String logMessageString;
	if (config.getLogInPlainString()) {
		StringBuilder sb = new StringBuilder();
		sb.append("[CID: ").append(logMessage.getCorrelationId());
		if (StringUtils.isNotBlank(logMessage.getCorrelationIdLocal())) {
			sb.append(" CID.Local: ").append(logMessage.getCorrelationIdLocal());
		}
		sb.append("] ").append(logMessage.getMessage());
		String varsInString = LogHelper.variablesToString(logMessage.getVariables(), config.getLogVariableType());
		if (varsInString.length() > 0) {
			sb.append(" [").append(varsInString).append("]");
		}
		if (logMessage.getThrowable() != null) {
			Throwable t = logMessage.getThrowable();
			sb.append("\nException: ").append(ExceptionUtils.getMessage(t)).append(" ")
					.append(ExceptionUtils.getStackTrace(logMessage.getThrowable()));
			sb.append("");
		}
		logMessageString = sb.toString();
	} else {
		TimeZone tz = TimeZone.getTimeZone("UTC");
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
		df.setTimeZone(tz);
		logMessage.setTimestamp(df.format(new Date()));
		logMessage.setLevel(level.toString());
		logMessage.setLogger(loggerName);
		logMessage.setThread(Thread.currentThread().toString());
		Gson gson = new GsonBuilder().disableHtmlEscaping().disableHtmlEscaping().create();
		logMessageString = gson.toJson(logMessage);
	}

	Logger logger = LogManager.getLogger(loggerName);
	switch (level) {
	case INFO:
		logger.info(logMessageString);
		break;
	case ERROR:
		logger.error(logMessageString);
		break;
	case FATAL:
		logger.fatal(logMessageString);
		break;
	case DEBUG:
		logger.debug(logMessageString);
		break;
	}
}
 
开发者ID:iac-m,项目名称:mule-json-logger,代码行数:49,代码来源:JsonLogger.java

示例10: flushLogs

import org.apache.log4j.Logger; //导入方法依赖的package包/类
/**
 * From http://stackoverflow.com/a/3187802/42171
 */
public static void flushLogs(Logger logger) {
    Logger root = Logger.getRootLogger();
    Set<FileAppender> flushed = new HashSet<FileAppender>();
    try {
        for (Appender appender : CollectionUtil.iterable(logger.getAllAppenders(), Appender.class)) {
            if (appender instanceof FileAppender) {
                FileAppender fileAppender = (FileAppender)appender;
                synchronized (fileAppender) {
                    if (!flushed.contains(fileAppender) && !fileAppender.getImmediateFlush()) {
                        root.info(String.format("Appender %s.%s is not doing an immediateFlush",
                                  logger.getName(), appender.getName()));
                        fileAppender.setImmediateFlush(true);
                        logger.info("FLUSH");
                        fileAppender.setImmediateFlush(false);
                        flushed.add(fileAppender);
                    } else {
                        root.info(String.format("Appender %s.%s is doing an immediateFlush",
                                  logger.getName(), appender.getName()));
                    }
                } // SYNCH
            } else {
                root.debug(String.format("Unable to flush non-file appender %s.%s",
                           logger.getName(), appender.getName()));
            }
        } // FOR (appender)
    } catch (Throwable ex) {
        root.error("Failed flushing logs for " + logger, ex);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:33,代码来源:LoggerUtil.java

示例11: clearMemory

import org.apache.log4j.Logger; //导入方法依赖的package包/类
public static void clearMemory(Logger logger) {
	logger.info("====> Recycling garbage...");
	printRAMInfo("Before: ", logger);
	Runtime.getRuntime().gc();
	printRAMInfo("After: ", logger);
	logger.info("========================================================================");
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:8,代码来源:RuntimeUtility.java

示例12: testEmojiRemover

import org.apache.log4j.Logger; //导入方法依赖的package包/类
public void testEmojiRemover() throws IOException {

        Logger log = Logger.getLogger(TwitterNormalizerTest.class);

        File folder = new File("/Users/Gideon/Documents/dev/Babel/scraping/lit/twitter");
        for (File tweetFile : folder.listFiles()) {
            String origData = FileUtils.readFileToString(tweetFile, "UTF-8");
            String data = new TwitterNormalizer().removeEmojis(origData);
            if (!origData.equals(data)) {
                log.info(origData);
                log.info(data);
            }
        }
    }
 
开发者ID:gidim,项目名称:Babler,代码行数:15,代码来源:TwitterNormalizerTest.java

示例13: testLog4j

import org.apache.log4j.Logger; //导入方法依赖的package包/类
@Test
public void testLog4j() throws InterruptedException, MQClientException {
    Logger logger = Logger.getLogger("testLogger");
    for (int i = 0; i < 50; i++) {
        logger.info("log4j " + this.getType() + " simple test message " + i);
    }
    int received = consumeMessages(30, "log4j",30);
    Assert.assertTrue(received>20);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:10,代码来源:Log4jTest.java

示例14: print

import org.apache.log4j.Logger; //导入方法依赖的package包/类
public TimeKeeper print(Logger logger, String message) {
    long diff = endDate.getTime() - startDate.getTime();
    long diffSeconds = diff / 1000 % 60;
    logger.info(String.format("%s ms:%d s:%d", message, diff, diffSeconds));

    return this;
}
 
开发者ID:cosminseceleanu,项目名称:movie-recommender,代码行数:8,代码来源:TimeKeeper.java

示例15: publish

import org.apache.log4j.Logger; //导入方法依赖的package包/类
@Override
public void publish(LogRecord record)
{
	Logger logger = Logger.getLogger(record.getLoggerName());
	Level level = record.getLevel();
	String message = record.getMessage();
	try
	{
		message = MessageFormat.format(record.getMessage(), record.getParameters());
	}
	catch( IllegalArgumentException ignore )
	{
		// message will possibly have placeholder format for its
		// parameters, such as
		// "frog went {0} on a {1} day", "walking", "summer's",
		// If format fails, send message in the raw.
	}
	if( record.getThrown() != null && !Check.isEmpty(record.getThrown().getLocalizedMessage()) )
	{
		message += '\n' + record.getThrown().getLocalizedMessage();
	}

	if( Level.SEVERE.equals(level) )
	{
		logger.fatal(message);
	}
	else if( Level.INFO.equals(level) )
	{
		logger.info(message);
	}
	else if( Level.WARNING.equals(level) )
	{
		logger.warn(message);
	}
	else if( Level.FINE.equals(level) || Level.FINER.equals(level) || Level.FINEST.equals(level) )
	{
		logger.trace(record);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:40,代码来源:ReportingServiceImpl.java


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