日志接口
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) } } }