We are frequently faced with the need to look at some detailed
information optionally logged by our runtime (as well as by the
MonoVM runtime in dotnet/runtime), and in order to obtain the necessary
data, we ask our users to perform a series of steps on the command line.
This is a task we can easily wrap in a nice target, so that instead
of having to type 5 lines of commands the user instead invokes a
single command which will do the rest for them:
dotnet build -t:RunWithLogging
The above command will:
1. Set the `debug.mono.log` Android system property
2. increase the `adb logcat` buffer size
3. clear the `adb logcat` buffer,
4. start the application waiting for it to be fully started
5. pause for 1s
6. dump the `adb logcat` buffer to a file.
7. Print a message mentioning where the `adb logcat` output is.
The `$(RunLogVerbose)` MSBuild property can be used to increase
verbosity. By default the `RunWithLogging` target will set
the `debug.mono.log` system property to:
default,assembly,timing=bare
When `$(RunLogVerbose)`=true, `debug.mono.log` is instead set to:
default,assembly,timing=bare,mono_log_level=debug,mono_log_mask=all
The `$(RunLogDelayInMS)` MSBuild property can be used to override the
pause in step (5).
The `$(_RunLogFilePath)` MSBuild property controls the output filename;
by default it is `$(IntermediateOutputPath)logcat.txt`.