大神JakeWharton的Timber是我写日志的最爱,几乎在所有的项目中都用。当然一般我会通过Timber使用Logger,原因很简单,因为Timber接口简洁,Logger的输出样式好看。常规套路:
FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder() .tag("DwGG") // (Optional) Global tag for every log. Default PRETTY_LOGGER .build(); Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy)); Timber.plant(new Timber.DebugTree() { @Override protected void log(int priority, String tag, String message, Throwable t) { Logger.log(priority, tag, message, t); } });