📄 logaspect.java
字号:
package com.royee.ecport.aop;
import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import com.royee.ecport.annotation.Description;
import com.royee.ecport.exception.ApplicationNotRunningException;
import com.royee.ecport.pojo.User;
import com.royee.ecport.web.actions.LoginAction;
/**
* 日志记录模块,记录Web层动作日志
* @author cfgxy
*
*/
public class LogAspect extends AspectFilter {
public void doFilter(JoinPoint jp) {
User u = null;
try {
Description description= getAnnotation(jp,Description.class);
if(description==null)
return;
u = (User) session().getAttribute(LoginAction.SESSION_KEY);
String username = (u == null ? "[guest]" : u.toString());
Logger.getLogger(jp.getTarget().getClass()).info(
description.value() + "(" + username + ")");
} catch (ApplicationNotRunningException e) {
Logger.getLogger(jp.getTarget().getClass()).debug(
"denified method used by spring.");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -