我試圖實現的logback-機器人,我都遵循相同的步驟,這裏所描述 in logback android的logback-機器人實現機器人沒有發生
我關於這些代碼是
<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清單中使用外部存儲權限 我正在使用模擬器創建一個10 MB sdcard文件夾。 但當我運行此代碼沒有文件和文件夾內創建。 需要幫助就在那裏我得到錯誤的感謝