我正在尝试实现 logback-android,我已经按照 logback android中描述的相同步骤进行操作
我的代码是
<configuration>
<!-- Create a file appender for a log in the application's data directory -->
<appender name="file" class="ch.qos.logback.core.RollingFileAppender">
<file>/sdcard/log/foo.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- Write INFO (and higher-level) messages to the log file -->
<root level="INFO">
<appender-ref ref="file" />
</root>
</configuration>
我的活动代码是
public class MainActivity extends Activity {
static private final Logger LOG =
LoggerFactory.getLogger(MainActivity.class);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BasicLogcatConfigurator.configureDefaultContext();
LOG.info("Hello Android!");
LOG.debug("reply: {}", Example.hello());
}
static class Example {
static private final Logger LOG =
LoggerFactory.getLogger(Example.class);
static public String hello() {
LOG.trace("entered hello()");
return "Hi there!";
}
}
}
我还在 android manifest 中使用外部存储权限我正在使用模拟器创建了一个 10 mb sdcard 文件夹。但是当我运行此代码时,不会在其中创建任何文件和文件夹。需要关于我哪里出错的帮助谢谢