日志初始化,可以合并成一句的
protected Logger m_logger =Logging.getLogger(this.getClass().getName());最好放在类一级的地方,比如public class MyClasss {
  protected Logger m_logger =Logging.getLogger(this.getClass().getName());
  ...

解决方案 »

  1.   

    那可否把这个日志初始化放到构造方法里再做??
    就是
    public class MyClasss {
    protected String ...;
    protected int ...;public MyClasss (){
      protected Logger m_logger =Logging.getLogger(this.getClass().getName());
      ...
    }
      

  2.   

    还有,这个日志Log4j是具体做什么用的?
      

  3.   

    1 你放到构造器里面就是个局部变量了,构造器结束,m_logger就没有了
    2 方法里面不允许有protected 等描述符
    3 如果改成这样,倒是可以的
    public class MyClasss {
      protected Logger m_logger = null;
      public MyClasss (){
        m_logger =Logging.getLogger(this.getClass().getName());
      }
    }4 log4j 是一个日志工具,你可以到google/baidu 去搜一下,太多了。
      

  4.   

    log4j很好用的
    可以好好看看