非WEB環境使用 log4j

import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;

import org.apache.commons.collections4.list.TreeList;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class Main {

    /**
     * 非WEB環境使用 log4j
     * 
     * @throws FileNotFoundException
     * @throws IOException
     */
    public static void logConfig() {
        URL url = ClassLoader.getSystemResource("log4j.properties");//必須在類路徑下
        PropertyConfigurator.configure(url);
    }

    public static void main(String[] args) {
        Logger log = Logger.getLogger(Main.class);
        log.info("info");
        TreeList<?> list;
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章