NEO

蜀道难,难于上青天!

导航

Grails指南摘要-402-logging

Posted on 2013-06-04 23:10  页面载入出错  阅读(254)  评论(0编辑  收藏  举报

日志接口

public interface Log {
public void debug(Object msg);
public void debug(Object msg, Throwable t);
public void error(Object msg);
public void error(Object msg, Throwable t);
public void fatal(Object msg);
public void fatal(Object msg, Throwable t);
public void info(Object msg);
public void info(Object msg, Throwable t);
public void trace(Object msg);
public void trace(Object msg, Throwable t);
public void warn(Object msg);
public void warn(Object msg, Throwable t);
public boolean isDebugEnabled();
public boolean isErrorEnabled();
public boolean isFatalEnabled();
public boolean isInfoEnabled();
public boolean isTraceEnabled();
public boolean isWarnEnabled();
}

使用日志消息

class SampleController {
  def index() {
    log.info('In the index action...')
    // ...
  }
}

使用错误日志

class SampleController {
  def index() {
    try {
      // do something that might throw an exception
    } catch (Exception e) {
      log.error ('some message goes here', e)
    }
  }
}