This is mainly to remove the custom logging with println and add correct logger and add a loglevel parameter to handle the log level.