new LogRecord(Level level, String msg) : LogRecord « java.util.logging « Java by API






new LogRecord(Level level, String msg)

  
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.MemoryHandler;

public class Main {
  public static void main(String args[]) throws Exception {
    Logger logger = Logger.getLogger("your.logging");
    ConsoleHandler handler = new ConsoleHandler();
    MemoryHandler mHandler = new MemoryHandler(handler, 10, Level.ALL);
    logger.addHandler(mHandler);
    logger.setUseParentHandlers(false);
    LogRecord record1 = new LogRecord(Level.SEVERE, "This is SEVERE level message");
    LogRecord record2 = new LogRecord(Level.WARNING, "This is WARNING level message");
    logger.log(record1);
    logger.log(record2);
  }
}

   
    
  








Related examples in the same category

1.LogRecord: getLevel()
2.LogRecord: getMessage()
3.LogRecord: getSourceClassName()
4.LogRecord: getSourceMethodName()