Code example for LogRecord

Methods: getLevelgetLoggerNamegetMessagegetParameters

0
    public String format (LogRecord r) {
      if (format) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        if (showLevel) {          
          sb.append(r.getLevel().getName());
        } 
        if (showName) {
          if (showLevel) {
            sb.append(":");
          } 
          sb.append(r.getLoggerName());
        } 
        sb.append("] ");
         
        String msg = r.getMessage();
        Object[] params = r.getParameters();
         
        if (params == null){
          sb.append(msg);
        } else { 
          sb.append(String.format(msg,params));
        } 
         
        return sb.toString();
         
      } else { // raw 
        return r.getMessage();
      } 
    } 
  } 
   
  public static String LOG_HOST = "localhost";
Experience pair programming with AI  Get Codota for Java