问题
I expected this to be a simple task, but I'm surprised to find no answers for this.
Let me clarify:
I do not want to call
adb logcat -c
manually. In fact, I'm not even using the command line to view LogCat, so I don't think this is possible (edit: actually, it is, by running the command in a separate command line...but I don't want to do that). I'm using Eclipse to view LogCat.I do not want to click button
Clear Log
each time. That's what I'm doing now.I do, programatically or through Eclipse's Run/Debug configurations or however, want a way to automatically clear LogCat each time I hit Ctrl+F11 to run my Android project. My LogCat is getting cluttered. Ctrl+F11 isn't important - it's just my shortcut to Debug. I'd like to clear LogCat on Debug/Run.
I'm using Eclipse on Windows 7 and debugging with a Nexus One (not an emulator).
I've tried:
Modifying Debug/Run configurations. (
Project
->Properties
->Run/Debug Settings
->Edit Launch Configurations
) Running from the emulator is the only way to addAdditional Emulator Command Line Options
. But I'm running from the actual Android device, so I can't access those options.Builders? I wasn't sure how to use this. (
Project
->Properties
->Builders
). How would I use this to clear LogCat each time I run?
I'm beginning to think I have to write a macro program to hook Ctrl+F11 when the active foreground process is eclipse.exe
to move my cursor to the Clear Log
button and click it. I guess clearing LogCat automatically is too much to ask for.
回答1:
If you're not locked to Eclipse because of some strong reasons, you can try IntelliJ IDEA as IDE. Here is option for run configuration for clear log on app run. Unfortunately, following http://youtrack.jetbrains.com/issue/IDEA-80976 it is broken right now, but I think it'll be fixed in near future.
回答2:
Some commercial releases of Eclipse (e.g. Adobe's Flash Builder) have this as an option in the preferences panel. It's probably a relatively trivial thing to implement, they just didn't bother.
You should request this feature, if enough people do it they might add it to the next release:
http://www.eclipse.org/contribute/
来源:https://stackoverflow.com/questions/9541639/automatically-clearing-logcat-on-each-eclipse-debug-run