Logs.java
955 Bytes
package com.diligrp.website.util.code;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* <p>Title: 〈标题〉</p>
* <p>Description: 〈描述〉</p>
* <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br />
* 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br />
* <B>Company</B> 地利集团
* <p>CreateTime:2014/7/3</p>
*
* @author zhukai
*/
public class Logs {
/**
* 返回以调用者的类命名的Log,是获取Log对象最简单的方法!
*/
public static Log get() {
StackTraceElement[] sts = Thread.currentThread().getStackTrace();
for (int i = 0; i < sts.length; i++) {
if (sts[i].getClassName().equals(Logs.class.getName())) {
return LogFactory.getLog(sts[i+1].getClassName());
}
}
return LogFactory.getLog(sts[2].getClassName());
}
}