Robolectric Logging

If you aren’t using Robolectric already to unit test your Android apps I’d suggest checking it out.

This is a quick post for people wondering where their Android log output is going when unit testing through the Robolectric test runner.

By default log output won’t go anywhere, however you can change this using the system property ‘robolectric.logging’.

The robolectric.logging system property should be set to one of three values:

  1. stdout – outputs to standard out
  2. stderr – outputs to … you guessed it
  3. /path/to/yourlog.log – outputs logs to a file (can be anything)

I put this as a VM argument to my run configuration for tests when I’m running within Eclipse:


Be aware that this solution only works in Robolectric 2.0.0-ALPHA-3 or greater.

Leave a Reply

Your email address will not be published. Required fields are marked *