Good evening and first of all thank you, I am creating a log file, for this I am using the java.util.logging library. The problem is that I have a Format class that inherits from Formatter and which allows me to format the log that I want, the problem is that the format defined by me does not work and shows it with the default format that is the xml, then I leave my class Format and my log configuration file
Formato.java
package com.formato;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import java.util.Date;
public class Formato extends Formatter{
public String format(LogRecord record){
Date fecha = new Date(record.getMillis());
return record.getLevel() + " [ " + fecha.toString() + " ] ( " +
record.getSourceClassName() + " method --> " +
record.getSourceMethodName() + " ) description: " + record.getMessage();
}
}
logging.properties
handlers=java.util.logging.FileHandler,java.util.logging.ConsoleHandler
.level=ALL
java.util.logging.FileHandler.level=ALL
java.util.logging.FileHandler.limit=1048576
java.util.logging.FileHandler.count=5
java.util.logging.FileHandler.append=false
java.util.logging.FileHandler.pattern=milog_%u_%g.log
java.util.logging.FileHandler.formatter=com.formato.Formato
java.util.logging.ConsoleHandler.level=OFF
As you can see in the Format class, I create a package and this package is called in the logging file indicating the package and the class that it has to call in the formatted formatter