90 lines
2.6 KiB
Java
90 lines
2.6 KiB
Java
|
package aiyh.utils.zwl.common.logging;
|
|||
|
|
|||
|
/**
|
|||
|
* 写日志(log4j)
|
|||
|
* @date 2020-03-10
|
|||
|
* @version 1.0
|
|||
|
*/
|
|||
|
public class Log4JLogger implements Logger {
|
|||
|
|
|||
|
private org.apache.log4j.Logger log;
|
|||
|
//类名
|
|||
|
private String classname;
|
|||
|
|
|||
|
@Override
|
|||
|
public String getClassname() {
|
|||
|
return classname;
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void setClassname(String classname) {
|
|||
|
this.classname = classname;
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public boolean isDebugEnabled() {
|
|||
|
return log.isDebugEnabled();
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public boolean isInfoEnabled() {
|
|||
|
return log.isInfoEnabled();
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void debug(Object message) {
|
|||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
|||
|
log.debug(classname+"."+method+"() - "+message);
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void debug(Object message, Throwable exception) {
|
|||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
|||
|
log.debug(classname+"."+method+"() - "+message, exception);
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void info(Object message) {
|
|||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
|||
|
log.info(classname+"."+method+"() - "+message);
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void info(Object message, Throwable exception) {
|
|||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
|||
|
log.info(classname+"."+method+"() - "+message, exception);
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void warn(Object message) {
|
|||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
|||
|
log.warn(classname+"."+method+"() - "+message);
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void warn(Object message, Throwable exception) {
|
|||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
|||
|
log.warn(classname+"."+method+"() - "+message, exception);
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void error(Object message) {
|
|||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
|||
|
log.error(classname+"."+method+"() - "+message);
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void error(Object message, Throwable exception) {
|
|||
|
String method = Thread.currentThread().getStackTrace()[2].getMethodName();
|
|||
|
log.error(classname+"."+method+"() - "+message, exception);
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public void init(String name) {
|
|||
|
if("".equals(name)) {
|
|||
|
name = "cuslog";
|
|||
|
}
|
|||
|
log = org.apache.log4j.Logger.getLogger(name);
|
|||
|
}
|
|||
|
}
|