Log And Exception Practice
来源:互联网 发布:java华容道代码 编辑:程序博客网 时间:2024/06/03 23:40
1.1 用log.error表示系统级错误
1.2 用log.warn表示应用级错误
1.3 服务初始化或结束用log.info
1.4 用log.debug替代out,debug要判断isDebugEnable
1.5 用log.warn("",e)替代e.printstack
1.6 用log4e生成log相关代码
1.7 Log信息要保证可读性,需记录现场信息,如当前处理id等
2 exception
2.1 try catch内的代码不要太长
2.2 因为性能原因,try catch少放循环内
2.3 尽量避免catch(Exception)这样的写法
2.4 不同模块定义不同的exception
2.5 建议创建应用的基类exception,特别是有定义error code需要的应用
2.6 只要catch就要log error message
2.7 catch并封装成另一种exception,如果不nest原来的exception就要log stackTrace
2.8 持久层throw dataAccessException,业务层throw checked exception,展现层只显示exception信息
2.9 规范的exception流程定义如下:
业务层不需处理的runtime exception,由展现层定义的exception controller捕获,交给相应的error页面显示并记录stack信息。业务层捕获下层的exception,并封装成业务层的checked exception,如果nest所捕获的exception,则仅log error message,如果不nest就需要用log.warn(“”,e)记录stack信息。展现层捕获业务层的exception,应由处理业务层exception的error页面来处理。
- Log And Exception Practice
- Exception log
- java log exception
- Theory and Practice
- Java theory and practice
- Ilasm And Ildasm Practice
- Preparation and Practice
- checked exception and unchecked exception
- Checked Exception and UnChecked Exception
- Design Pattern Introduction and Practice
- Configuration Management Principles and Practice
- Information security: principles and practice
- ADO Examples and Best Practice
- XML in Theory and Practice
- Web Services: Theory and Practice
- Game Design: Theory and Practice
- Systems Modelling: Theory and Practice
- Modern Cryptography: Theory and Practice
- mysql移植到mini2440
- Android实现利用手势完成屏幕密码锁功能
- 进程与线程的异同及意义
- 最简单的 BorderLayout布局例子:
- [转] 一个女生写给男朋友的!!!~~有点现实、冷静的语言,却让人感觉很温暖!!!
- Log And Exception Practice
- ASP.NET Postback回调后参数无效
- Log
- svn
- linux 之declare 命令
- 浅谈构造函数与析构函数的调用顺序
- 团队建设
- QQ登录接口集成,QQ+登录ASP.net+代码,+QQ+oauth的使用
- acm pku 1064 cable master