01: package com.technoetic.xplanner.util;
02:
03: import org.apache.log4j.Logger;
04:
05: public class LogUtil {
06: public static String getCallerMethod() {
07: String methodName = "";
08: StackTraceElement[] stackTrace = new Throwable()
09: .getStackTrace();
10: if (stackTrace != null) {
11: methodName = stackTrace[2].getClassName() + "."
12: + stackTrace[2].getMethodName();
13: }
14:
15: return methodName;
16: }
17:
18: public static String getCallerClass() {
19: String className = "";
20: StackTraceElement[] stackTrace = new Throwable()
21: .getStackTrace();
22: if (stackTrace != null) {
23: className = stackTrace[2].getClassName();
24: }
25:
26: return className;
27: }
28:
29: public static Logger getLogger(Class c) {
30: return Logger.getLogger(c.getName());
31: }
32:
33: public static Logger getLogger() {
34: return Logger.getLogger(getCallerClass());
35: }
36: }
|