Can now switch loggin output to file or stdout with DEBUG switch.