Follow these steps to implement the example:
- Create a class named MyFormatter that extends the java.util.logging.Formatter class. Implement the abstract format() method. It receives a LogRecord object as a parameter and returns a String object with a log message:
public class MyFormatter extends Formatter { @Override public String format(LogRecord record) { StringBuilder sb=new StringBuilder(); sb.append("["+record.getLevel()+"] - "); sb.append(new Date(record.getMillis())+" : "); sb.append(record.getSourceClassName()+ "." +record.getSourceMethodName()+" : "); sb.append(record.getMessage()+"\n");. return sb.toString(); }
- Create a class named MyLoggerFactory:
public class MyLoggerFactory {
- Declare a private ...