Trans.exec(new Atom(){
public void run() {
//事务中,抛异常
throw new RuntimeException("已投过票,明天再来");
});
public void process(ActionContext ac) throws Throwable {
String uri = Mvcs.getRequestPath(ac.getRequest());
if (log.isWarnEnabled()) {
log.warn(String.format("Error@%s :", uri), ac.getError());
ProcessorUtil.getResponse(ac, null);// 返回响应
return;
}
if (log.isErrorEnabled()) {
//这块打日志,拿响应会特别慢
log.error(String.format("Error@%s :", uri), ac.getError());
}
super.process(ac);
}
//上面 统一异常处理方法
//log.warn() 响应正常
//这两天改成 log.error() 拿响应特别慢,造成数据库死锁
//日志信息
org.apache.catalina.connector.ClientAbortException: java.io.IOException: 远程主机强迫关闭了一个现有的连接。
Caused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
if (log.isWarnEnabled()) {
log.warn(String.format("Error@%s :", uri), ac.getError());
ProcessorUtil.getResponse(ac, null);// 返回响应
return;
}
if (log.isErrorEnabled()) {
//这块打日志,拿响应会特别慢
log.error(String.format("Error@%s :", uri), ac.getError());
}
为啥warn有return,error反而没有
这根据日志级别来执行业务逻辑,很不好
@qq_ec453099 warn响应速度正常,error响应慢,多点请求几次,就过挂掉了
来自炫酷的 NutzCN
log.error 响应慢跟配置有关系么,还是?
log4j.rootLogger=debug,Console,mail,warn,info
log4j.logger.org.nutz.dao.impl.sql.run.NutDaoExecutor=info
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d %l %-5p - %m%n
error log info sending mail
log4j.appender.mail=org.apache.log4j.net.SMTPAppender
log4j.appender.mail.Threshold=error
log4j.appender.mail.smtp.auth=true
log4j.appender.mail.BufferSize=512
log4j.appender.mail.SMTPHost=smtp.sina.com
log4j.appender.mail.Subject=\u65E5\u5FD7\u5F02\u5E38\u4FE1\u606F
log4j.appender.mail.SMTPUsername=
log4j.appender.mail.SMTPPassword=
log4j.appender.mail.From=
log4j.appender.mail.To=
log4j.appender.mail.layout=org.apache.log4j.HTMLLayout
log4j.appender.mail.layout.ConversionPattern=[ErrorMessage] %d - %c -%-4r [%t] %-5p %c %x - %m%n
```