Remove hard dependency on log4j (rebased onto develop)

This is the same as #368 but rebased onto develop.