eclipse 如何将 logcat 输出复制到剪贴板?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11608718/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to copy logcat output to clipboard?
提问by Guanlun
I'm developing android apps in eclipse and how can I get logcat messages to my clipboard?
我正在 eclipse 中开发 android 应用程序,如何将 logcat 消息发送到剪贴板?
回答by Uriel Frankel
Select the message and press ctrl+c. You can save it in a text file using this button:
选择消息并按ctrl+ c。您可以使用此按钮将其保存在文本文件中:
If you are using mac a workaround is to right click, find similar messages, then copy from dialog. – Thank you Snicolas
如果您使用的是 mac,解决方法是右键单击,找到类似的消息,然后从对话框中复制。– 谢谢斯尼科拉斯
回答by Mike T
You can click on the output line in LogCat and click ctrl+clike normal then a normal paste into whatever you want. You can use shift and click to select multiple lines.
您可以单击 LogCat 中的输出行,然后像正常一样单击ctrl+,c然后正常粘贴到您想要的任何内容中。您可以使用 shift 并单击来选择多行。
回答by Meanman
Ctrl+ Cworks but you need to make sure to make sure you click on the first line of any output that is split into multiple lines.
Ctrl+C有效,但您需要确保单击任何分成多行的输出的第一行。
回答by gprathour
Copy only what is required in Android Studio
仅复制 Android Studio 中所需的内容
Out of the curiosity I thought to post this answer. By default Logcat shows other information also along with the logs like Date Time, Process and Threads, Package name and Tag and if you copy a line from Logcat then this whole information is copied as well.
出于好奇,我想发布这个答案。默认情况下,Logcat 还显示其他信息以及日志,如日期时间、进程和线程、包名称和标签,如果您从 Logcat 复制一行,那么整个信息也会被复制。
In case you don't want this at all or you don't want a particular thing then you can do something like this,
如果你根本不想要这个或者你不想要特定的东西,那么你可以做这样的事情,
Step 1:
第1步:
Click on Logcat Header(Settings/Gear) icon
单击 Logcat Header(设置/齿轮)图标
Step 2:
第2步:
Untick whatever you don't want to see in the logs and ultimately you don't want to copy.
取消您不想在日志中看到的任何内容,最终您不想复制。
That's it.
就是这样。
I thought it might help someone.
我认为这可能会帮助某人。
P.S. The question is very old and asked at the time of Eclipse, but this answer is new and is for Android Studio.
PS 这个问题很老,在 Eclipse 的时候问过,但这个答案是新的,是针对 Android Studio 的。
回答by Red Baron
From a command line:
从命令行:
adb logcat > log.txt
回答by CCJ
Also notable is that as of at least ADT plugin version 21 there is a TID column displayed in Eclipse's logcat viewer when you have display settings on maximum verbosity, but the thread id will not be preserved if you copy and paste the content of this view. Instead you'll see something like [debug level] [timestamp] [invocation] (PID)... but no thread id. I don't know if there is an easier way to grab the TID data directly from eclipse, but it can be done using a remote adb shell as follows:
另外值得注意的是,至少从 ADT 插件版本 21 开始,当您将显示设置设为最大详细程度时,Eclipse 的 logcat 查看器中会显示一个 TID 列,但如果您复制并粘贴此视图的内容,则不会保留线程 ID。相反,您会看到类似 [debug level] [timestamp] [invocation] (PID)... 但没有线程 id 的内容。我不知道是否有更简单的方法可以直接从 eclipse 中获取 TID 数据,但是可以使用远程 adb shell 来完成,如下所示:
Execute the following from your PC's command line: adb -s [your device's serial number] shell "logcat -v threadtime" > [your_output_file]
从您的 PC 命令行执行以下命令: adb -s [您设备的序列号] shell "logcat -v threadtime" > [your_output_file]
your session will appear to hang, but in actuality the device's logcat output, exactly as shown in eclipse's logcat view including the TID, is being written in real time to your output file. When you want to view the content, exit the logcat dump process with ctrl+cand open the file on your PC. Other options for logcat filtering etc. can be found [here].1
您的会话看起来会挂起,但实际上,设备的 logcat 输出(与 eclipse 的 logcat 视图(包括 TID)中显示的完全一样)正在实时写入您的输出文件。当您要查看内容时,请使用ctrl+退出 logcat 转储过程c并在您的 PC 上打开该文件。可以在 [此处] 找到其他用于 logcat 过滤等的选项。1
回答by Scott Biggs
For those of you working with Eclipse on a Macintosh, here's a work-around:
对于那些在 Macintosh 上使用 Eclipse 的人,这里有一个解决方法:
- Highlight the parts of the logcat you want to copy to the clipboard (or just select everything by clicking ctrl-awhen the logcat window is active)
- Click on the "save" icon (it looks like a floppy disk)
- Save it to a convenient location
- Open the log file in another text editor (use your favorite that is NOT eclipse)
- Select what you want
- Now type ctrl-cto copy to the clipboard
- 突出显示要复制到剪贴板的 logcat 部分(或者只需单击选择所有内容ctrl-a当 logcat 窗口处于活动状态时)
- 点击“保存”图标(看起来像软盘)
- 将其保存到方便的位置
- 在另一个文本编辑器中打开日志文件(使用你最喜欢的不是 eclipse)
- 选择你想要的
- 现在输入ctrl-c复制到剪贴板
Yup, I know; it's a pain in the ass, but it works.
是的,我知道;这是一个痛苦的屁股,但它的工作原理。
回答by dcarl661
put cursor in the logcat window. ctrl-aselect all ctrl-ccopy what's selected (which will be all) run vi then paste.
将光标放在 logcat 窗口中。 ctrl- 全a选 ctrl-c复制选择的内容(将是全部)运行 vi 然后粘贴。
回答by BlueSpectrumz
Here is a technique for copying multiple data columns from Logcat, to paste in a spreadsheet.
这是一种从 Logcat 复制多个数据列以粘贴到电子表格中的技术。
Format your Log data with consistent padding (spaces, zeroes). Separate the data with tabs (tabs work with Google Sheets). Use a tag to filter the Logcat output.
使用一致的填充(空格、零)格式化您的日志数据。用制表符分隔数据(制表符适用于 Google 表格)。使用标签过滤 Logcat 输出。
Log.d("MY_TAG", String.format(Locale.ENGLISH, "value1, value2 %08d\t%03d", data1, data2));
After the app has produced some output, in the Logcat window hold down the ALT key, and drag down to select the columns.
在应用程序产生一些输出后,在 Logcat 窗口中按住 ALT 键,并向下拖动以选择列。
Use CTRL+C(Windows) to copy to clipboard.
使用CTRL+C(Windows) 复制到剪贴板。
Navigate to a spreadsheet (Google Sheets), select a starting cell, and use CTRL+Vto paste the columns into the spreadsheet.
导航到电子表格(Google 表格),选择一个起始单元格,然后使用CTRL+V将列粘贴到电子表格中。