On trying to have a custom handler for Tomcat (using java.util.logging), I could not find a way to have a custom property added.
E.g. how to set a value of abc property of the handler?
# logging.properties
handlers = java.util.logging.ConsoleHandler, com.company.tomcat.JdbcHandler
.handlers = java.util.logging.ConsoleHandler, com.company.tomcat.JdbcHandler
com.company.tomcat.JdbcHandler.level = FINE
com.company.tomcat.JdbcHandler.abc=hello
package com.company.tomcat;
public class JdbcHandler extends Handler {
private String abc;
public void setAbc(String abc) {
this.abc = abc; // this is not set
}
@Override
public void publish(LogRecord record) {
System.out.println("record " + record); // this is called
}
...
}
For the JDK and Tomcat the custom handler must interact with the LogManager on creation to read the parsed and loaded values. You have to set all of the properties defined by the java.util.logging.Handler class along with your new properties.
Here is an example to get you started:
It is worth keeping the public
setAbcmethod as WildFly will use that method to assign the property.