You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows下adb logcat重定向日志文件中文乱码问题求助

解决adb logcat重定向日志中文乱码问题

问题原因

Windows CMD默认采用GBK编码,而adb logcat输出的是UTF-8编码,直接重定向时会因编码不匹配导致中文乱码;PowerShell 7和Android Studio默认以UTF-8编码处理输出,因此显示正常。

解决方法

  • 使用PowerShell 7执行重定向
    直接在PowerShell 7中运行命令,默认会以UTF-8编码保存日志:

    adb logcat > file.log
    

    也可以显式指定编码,确保兼容性:

    adb logcat | Out-File -FilePath file.log -Encoding UTF8
    
  • 在CMD中切换编码后执行
    先将CMD的编码切换为UTF-8,再执行重定向命令:

    chcp 65001
    adb logcat > file.log
    
  • 通过Android Studio导出日志
    在Android Studio的Logcat面板中,点击右上角的导出图标(📤),选择保存路径即可直接获取UTF-8编码、中文显示正常的日志文件。

内容的提问来源于stack exchange,提问作者Ken Lee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 20:12:49