我正在使用log4j进行日志记录,为了在执行过程中获取相应方法的类名,我有一些常见的方法使用SecurityManager来获取类名,但我不想使用SecurityManager,有没有其他方法在运行时获取类名。另外,我不想在每个类中编写代码(
MyClass.getClassName
)来获取类名。class log extends SecurityManager {
public String getClassName() {
return getClassContext()[3].getName();
}
}