Java logger that automatically determines caller's class name

后端 未结 21 723
礼貌的吻别
礼貌的吻别 2020-12-07 17:53
public static Logger getLogger() {
    final Throwable t = new Throwable();
    final StackTraceElement methodCaller = t.getStackTrace()[1];
    final Logger logger          


        
21条回答
  •  时光说笑
    2020-12-07 18:36

    I prefer creating a (static) Logger for each class (with it's explicit class name). I than use the logger as is.

提交回复
热议问题