1. 導入如上 log下的對應jar包html
2. 在src下新建log4j.properties文件,類容如(詳細配置:http://www.cnblogs.com/suman/archive/2010/10/23/1858864.html )apache
3.編寫代碼this
import org.apache.commons.logging.Log; url
import org.apache.commons.logging.LogFactory;htm
Log log = LogFactory.getLog( this .getClass()); blog
四、附件爲參考例子get