Code example for LogRecord

Methods: setLoggerName, setMillis, setThreadID

0
 
    @Test 
    public void test() throws Exception { 
        Date currentTime = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss").parse("2012/01/22 10:01:11");
 
        LogRecord record = new LogRecord(Level.INFO, "this is test message.");
        record.setLoggerName("testLogger");
        record.setMillis(currentTime.getTime());
        record.setThreadID(10);
 
        String actual = formatter.format(record);
        assertThat(actual,is("2012-01-22 10:01:11.000 testLogger INFO {10} - this is test message.\n"));
    } 
 
}