发表于: 2018-05-19 23:03:14
1 1173
今天完成的事情:
学习了用日志记录项目信息,过滤日志信息:
在web.xml中配置日志:
<!-- log4j配置,文件路径,因为是跟随项目启动 -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<!-- 3000表示 开一条watchdog线程每60秒扫描一下配置文件的变化;这样便于日志存放位置的改变 -->
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>3000</param-value>
</context-param>
<!-- 加载log4j配置文件 -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
在spring中配置aop
<!-- 6.添加Controller切面 -->
<aop:aspectj-autoproxy />
<bean name="timerAspectController" class="com.mvc.aop.TimeController"/>
<aop:aspectj-autoproxy />
<bean name="timeAspectUserService" class="com.mvc.aop.TimeUserService"/>
创建一个性能监控信息实体类:
public class MonitorTime {
// 类名
private String className;
// 方法名
private String methodName;
// 时间
private Date logTime;
// 计算时间
private Long comsumeTime;
@Override
public String toString() {
return "MonitorTime{" +
"className='" + className + '\'' +
", methodName='" + methodName + '\'' +
", logTime='" + logTime + '\'' +
", comsumeTime=" + comsumeTime +
'}';
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public Date getLogTime() {
return logTime;
}
public void setLogTime(Date logTime) {
this.logTime = logTime;
}
public Long getComsumeTime() {
return comsumeTime;
}
public void setComsumeTime(Long comsumeTime) {
this.comsumeTime = comsumeTime;
}
}
明天计划的事情:(学习配置aop的类)
遇到的问题:
收获:(通过今天的学习,学到了什么知识)
最后,劳烦师兄批阅了
评论