設置Logcat預設大小(Android 5以後)
Android 5.0之後採用logd作為logcat處理界面,先前在kernel設置logcat預設大小的方式,已經無法正確生效。
在LogBuffer::init()內可以看到logd設置logcat大小的方法
system/core/logd/LogBuffer.cpp
void LogBuffer::init() {
static const char global_tuneable[] = "persist.logd.size";
static const char global_default[] = "ro.logd.size"
unsigned long default_size = property_get_size(global_tuneable);
板子自帶logcat大小,在系統Property中"ro.logd.size"
全域logcat大小,可設置系統Property "persist.logd.size"
各自logcat大小,可設置系統Property
"persist.logd.size.main"
"persist.logd.size.radio"
"persist.logd.size.events"
"persist.logd.size.system"
"persist.logd.size.crash"
"persist.logd.size.security"
"persist.logd.size.kernel"
上面的名稱定義在
system/core/liblog/logger_name.c
static const char *LOG_NAME[LOG_ID_MAX] = {
[LOG_ID_MAIN] = "main",
[LOG_ID_RADIO] = "radio",
[LOG_ID_EVENTS] = "events",
[LOG_ID_SYSTEM] = "system",
[LOG_ID_CRASH] = "crash",
[LOG_ID_SECURITY] = "security",
[LOG_ID_KERNEL] = "kernel",
};
logd讀取logcat大小設定的優先順序是:(1)各自logcat大小 (2)全域logcat大小 (3)板子自帶logcat大小 (4)一般logcat設定(256K) (5)最小logcat設定(64K)
logcat -g可以查詢當前logcat大小設置
http://blog.csdn.net/kc58236582/article/details/51073489
http://newandroidbook.com/Book/logd.pdf
留言