如何设置把MyEclipse的Console输出到文件
在JAVA程序上右键--> Run As --> Run Configurations
选择Common窗口,设置文件保存路径,以及是否以追加方式保存console输出到文件。
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Log log=LogFactory.getLog("--start--");
log.fatal("this id a fatal message");
log.error("this id a error message");
log.warn("this id a warn message");
log.info("this id a info message");
if(log.isDebugEnabled()){
log.debug("this id a debug message");
}
LoginForm loginForm = (LoginForm) form;// TODO Auto-generated method stub
String name=loginForm.getName();
String password=loginForm.getPassword();
if(name.equals("abc")&&password.equals("111")){
return mapping.findForward("go");
}else{
return mapping.findForward("go1");
}
}
log4j.rootLogger=INFO,console,file
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=d:/Log/log.html
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%r%t%p-%m%n
log4j.appender.file.layout=org.apache.log4j.HTMLLayout
以上就是如何设置把MyEclipse的Console输出到文件的详细内容,更多请关注其它相关文章!
推荐阅读