原文出处:http://www.vipan.com/
e-mail:envelop@163.com 【程序编程相关:JNLP文件模板】译者:醉了~白 【推荐阅读:Castor学习笔记(一)】正文: 【扩展信息:准备开放我的工作流客户端开源程序】中文标题:log4j快速入门及参考资料第一部分,快速入门首先,需要去下载log4j这个软件并解压缩出其中的log4j.jar.在你的应用程序的classpath中包含该jar文件,你也可以简单地将这个文件拷贝到jdk的%java_home%\lib\ext目录下.
在作完以上工作后,你可以将下面的代码保存到名为testlogging.java中:##############################import org.apache.log4j.*;// how to use log4j
public class testlogging {// initialize a logging category. here, we get the root category
//static category cat = category.getroot(); // or, get a custom category static category cat = category.getinstance(testlogging.class.getname());// from here on, log away! methods are: cat.debug(your_message_string),
// cat.info(...), cat.warn(...), cat.error(...), cat.fatal(...)public static void main(string args[]) {
// try a few logging methods cat.debug("start of main()"); cat.info("just testing a log message with priority set to info"); cat.warn("just testing a log message with priority set to warn"); cat.error("just testing a log message with priority set to error"); cat.fatal("just testing a log message with priority set to fatal");// alternate but inconvenient form
cat.log(priority.debug, "calling init()");new testlogging().init();
}public void init() {
java.util.properties prop = system.getproperties(); java.util.enumeration enum = prop.propertynames();cat.info("***system environment as seen by java***");
cat.debug("***format: property = value***");... 下一页