log4j配置文件的手動加載與配置初始化

一. 本地項目: 初始化log4j的日誌配置,指定到src目錄下(建議用2)
        //1. 本地項目-屬性文件配置
        PropertyConfigurator.configure("src/config/log4j.properties");
        //2. 本地項目-xml文件配置
        DOMConfigurator.configure("src/config/log4j.xml");
        //3. 本地項目-默認配置
        BasicConfigurator.configure();
        
二. web項目初始化: 初始化log4j的日誌配置,在web.xml中
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>classpath:config/log4j.xml</param-value>
    </context-param>





附件列表

相關文章
相關標籤/搜索