Changed so when debug is enabled, it will log debug output to log file