code: private static void writeToLog(Logger logger, Level level, String pattern, Exception exception) {
      if (level == Level.ERROR) {
        logger.error(pattern, exception);
      } else if (level == Level.INFO) {
        logger.info(pattern);
      } else if (level == Level.DEBUG) {
        logger.debug(pattern);
      }
    }
docs: Write the given pattern to given log in given logging level
  @param logger
  @param level
  @param pattern
  @param exception