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

如何使用ProGuard Retrace还原带时间格式的完整Logcat日志?

Can Retrace Restore Entire Logcat Log Files?

Short answer: Retrace doesn't automatically process regular Logcat log entries (like the one in your example) out of the box—its default behavior is only to deobfuscate stack trace lines. That's why your current command isn't changing the output at all.

Let's break down what's going on and how to fix it:

Why Your Current Command Isn't Working

Your Logcat entries look like this:

01-22 09:03:53.482 D/com.mydomain.myapp.g.a.c( 5255): Some logcat message

Retrace's default regex is built to match stack trace lines (e.g., at com.mydomain.myapp.g.a.c.someMethod(SourceFile:123)), not the standard Logcat entry format. The custom regex you used ((?:.*/)%c(?:.*)) is too vague—it doesn't properly target the obfuscated class name in your Logcat structure, so Retrace can't identify what needs to be replaced.

How to Deobfuscate Entire Logcat Entries

You can make Retrace process your Logcat logs by defining a precise custom regex that tells it exactly where the obfuscated class name sits in each line.

For your specific Logcat format, use this modified command:

.\retrace.bat -regex "^(\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}) [VDIWE]/%c\(\s*\d+\): (.*)$" .\mapping.txt .\test.log > .\test_retraced.log

Here's what the regex does:

  • ^(\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}): Captures the timestamp at the start of each line
  • [VDIWE]/: Matches the Logcat log level (Verbose/Debug/Info/Warning/Error)
  • %c: The special placeholder Retrace uses to spot the obfuscated class name it needs to deobfuscate
  • \(\s*\d+\): Matches the process ID wrapped in parentheses
  • : (.*)$: Captures the rest of the log message

Critical Notes

  • Use the correct mapping file: Your mapping.txt must be the exact file generated during the obfuscation of the app build that produced the Logcat logs. Using the wrong mapping will result in no deobfuscation or incorrect results.
  • Tweak the regex if needed: If your Logcat lines have minor variations (like extra spacing or custom tags), adjust the regex to match your actual log format. The key is placing %c exactly where the obfuscated class name appears.

Alternative: Use a Custom Script

If Retrace's regex feels too rigid, you can write a simple script (Python, Shell, etc.) to handle deobfuscation manually:

  1. Parse mapping.txt to create a dictionary mapping obfuscated class names to their original names.
  2. Loop through each line in your Logcat file.
  3. Replace any obfuscated class names in the lines with their original counterparts using the dictionary.

This approach gives you more flexibility to handle edge cases or non-standard log formats.

内容的提问来源于stack exchange,提问作者JM Lord

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 03:54:00