how to configure my own formatter in java logging property file
- by loudiyimo
For my java project, i am using the java logging api. I want to log everything using a property file.
Before using this file (log.properties), I configured my onwn fommater in the java code. (see below)
Now I want to configure my own fomater in the propertie file, instead of the java code.
does someone know how to do that ?
Formatter formatter = new Formatter() {
@Override
public String format(LogRecord arg0) {
StringBuilder b = new StringBuilder();
b.append(new Date());
b.append(" ");
b.append(arg0.getSourceClassName());
b.append(" ");
b.append(arg0.getSourceMethodName());
b.append(" ");
b.append(arg0.getLevel());
b.append(" ");
b.append(arg0.getMessage());
b.append(System.getProperty("line.separator"));
return b.toString();
}
};
fomatter in the java code
..... .....
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=WARNING
java.util.logging.??? = how can i configure my own formater in the property files with this information: data, clasename, methodename, level .etc.**
formatter in de log.proprties