API for setting logfile level and additional refactoring