Code example for LogRecord

Methods: getLevel, getLoggerName, getMessage, getMillis

0
    private static final DateFormat format = new SimpleDateFormat("h:mm:ss"); 
    private static final String lineSep = System.getProperty("line.separator"); 
     
    public String format (LogRecord record)  
    { 
        String loggerName = record.getLoggerName(); 
        if (loggerName == null) 	loggerName = "root"; 
         
        StringBuilder output = new StringBuilder() 
            .append("[") 
            .append(format.format (new Date(record.getMillis()))) 
            .append("][") 
            .append(Thread.currentThread().getName()) 
            .append("][") 
            .append(record.getLevel()) 
            .append("][") 
            .append(loggerName) 
            .append("]: ") 
            .append(record.getMessage()).append(' ') 
            .append(lineSep); 
         
        return output.toString();