Code example for LogRecord

Methods: setSourceClassNamesetSourceMethodName

0
      // record, and getting the class and method names from it. 
      // This may look like a hack, but it's pretty much no worse than anything 
      // else, we'll need to create a new Object, no matter what. Hey, we need 
      // the stack trace, so this is peanuts compared to that. 
      Record rec = new Record(Level.INFO, null);
      lr.setSourceClassName(rec.getSourceClassName());
      lr.setSourceMethodName(rec.getSourceMethodName());
    } 
    logger.log(lr);
  } 
 
  /** 
   * Logs an event with a known context, similar to 
   * {@link java.util.logging.Logger#logp(java.util.logging.Level, String, String, String)}. 
   * However, this delays formatting of the message. 
   * @param level one of the message level identifiers, e.g. SEVERE 
   * @param sourceClassName the class generating this log event 
   * @param sourceMethodName the method generating this log event 
   * @param msg the basic message string 
   * @param params the parameters for the message string