带占位符的日志格式

  • Post author:
  • Post category:其他


package liulixin;

import java.util.logging.Level;
import java.util.logging.Logger;

public class riZhiGeShi {
	private static final Logger LOGGER = Logger.getLogger(riZhiGeShi.class.getName());

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		LOGGER.log(Level.INFO,"刘利新西安");
		LOGGER.log(Level.INFO,"{0}","刘利新西安");
		LOGGER.log(Level.INFO,"{0}{1}{2}",new Object[]{"刘利新",System.getProperty("line.separator"),"西安"});

	}

}

输出:

七月 08, 2013 2:11:46 下午 liulixin.riZhiGeShi main

INFO: 刘利新西安

七月 08, 2013 2:11:47 下午 liulixin.riZhiGeShi main

INFO: 刘利新西安

七月 08, 2013 2:11:47 下午 liulixin.riZhiGeShi main

INFO: 刘利新

西安



版权声明:本文为weiyanghuadi原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。