eclipse下日志文件(log4j)打印到 控制台输出 如何做到可以点击错误提示跳转到指定代码行

2024-11-01 23:49:48
推荐回答(2个)
回答1:

要导入log4j jar包,搂主导了吗没,要可以说声,邮箱留个给我我可以帮你发过去

回答2:

private Static final Log log=LogFactor.getLog(类.class);
输出日志是就可用
log.debug(" 你想要输出的内容(可以加变量值)");
例子:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.starting.dao.BorrowDAO;
import com.starting.dao.GoodsDAO;
import com.starting.po.Borrow;

public class Borrowdaoimpl extends HibernateDaoSupport implements BorrowDAO {
private static final Log log=LogFactory.getLog(Borrowdaoimpl.class);
@Override
public void delecBorrow(Borrow e) {
// TODO Auto-generated method stub
log.debug("delectBorrow");
try {

} catch (RuntimeException es) {
// TODO: handle exception
log.debug("delectBorrow fail");
throw es;
}

}