Search code examples
androidunity-game-engineadbremote-debugging

How to prevent UnityEngine.Debug.Log writing multiple lines to ADB


I am using ADB to log in Windows PowerShell from a Unity built application running on a connected Android device. I am only interested in my own message invoked in script from e.g. UnityEngine.Debug.Log("## State set to SolvingAnchor"), but Unity appends 8 lines to this message:

  • .\adb logcat -s Unity -e "^[#]{2}" -m 1
  • --------- beginning of crash
  • --------- beginning of system
  • --------- beginning of main
  • 02-11 10:07:42.658 8293 8315 I Unity : ## State set to SolvingAnchor
  • 02-11 10:07:42.658 8293 8315 I Unity : UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
  • 02-11 10:07:42.658 8293 8315 I Unity : UnityEngine.Logger:Log(LogType, Object)
  • 02-11 10:07:42.658 8293 8315 I Unity : UnityEngine.Debug:Log(Object)
  • 02-11 10:07:42.658 8293 8315 I Unity : Assets.Scripts.TrackedImageHandler:SetState(State)
  • 02-11 10:07:42.658 8293 8315 I Unity : Assets.Scripts.TrackedImageHandler:Update()

  • 02-11 10:07:42.658 8293 8315 I Unity :

  • 02-11 10:07:42.658 8293 8315 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
  • 02-11 10:07:42.658 8293 8315 I Unity :

As seen in the output filtering on regex is not working as I would have hoped. Is there a way to only print the message and skip the Unity generated redundant lines?


Solution

  • In the Project Settings > Player > Android > Other Settings > Logging set all Logging Types to None or Script Only.

    This will keep the ADB logcat rather compact.

    Player Settings > Log Type