The following terminal command shows the logcat.
$> $SDK/platform-tools/adb logcat
But how do I g开发者_开发知识库et out of it to go back to the terminal prompt? I tried kill-server, exit etc.
Ctrl + C
Using -d option will get you a one-time run of logcat.
adb logcat -d
Instead of looping, it will go back to command prompt after it prints out all the logs from log buffer. Each time you use this command, it always starts from the beginning of log buffer, unless you input the command below to clean the logs in log buffer:
adb logcat -c
The command above is to clean the logs in logcat buffer.
My Suggestion:
$> $SDK/platform-tools/adb logcat -c
$> $SDK/platform-tools/adb logcat > log_file.txt &
... run your application ...
$> $SDK/platform-tools/adb logcat -c
Logcat Documentation
-c Clears (flushes) the entire log and exits.
I found an issue when trying with solution of Meir Gerenstadt.
The adb logcat -c
at the end doesn't really stop logcat from writing to the log_file.txt
My solution is:
# Clear logcat
$> $SDK/platform-tools/adb logcat -c
# Redirect logcat to file, in background process.
$> $SDK/platform-tools/adb logcat > log_file.txt &
# Get process id of logcat background process above
$> logcat_pid=$!
... run your application ...
# Now kill the logcat background process
$> kill $logcat_pid
You can suspend the process by sending it a SIGSTP signal using CTRL+Z and issue any command you wish to, then to restart issue:
$> fg -1
Assuming you did not suspend or start any other background process from the terminal.
精彩评论