J2me 中使用 Log, 可以使用搜索引擎搜索下载 log4j2me.
使用方法和 j2se 中有一些区别,下面是在 log4j2me 包中的一个例子
package log4j2me.test;
import org.apache.log4j.*;
import org.apache.log4j.helpers.LogLog;
/**
Very simple log4j usage example.
@author Ceki Gülcü, Witmate
*/
// Modifiers: Witmate [Nov,2004: Modified for log4j2me]
public class Hello {
static Category log = Category.getInstance(Hello.class);
static Category log1 = Category.getInstance("Hello");
public static void main(String argv[]) {
Category root = Category.getRoot();
root.setPriority( Priority.DEBUG );
Layout layout = new PatternLayout("%p [%t] %c - %m%n");
try {
root.addAppender(new FileAppender(layout, System.out));
} catch(Exception e) {
LogLog.warn("Could not open file appender.");
}
log.debug("Hello world.");
log.info("What a beatiful day.");
log1.debug("Hello world.");
log1.info("What a beatiful day.");
}
}
posted on 2010-01-28 01:13
lincode 阅读(362)
评论(0) 编辑 收藏 所属分类:
Java