use of java.util.logging.ErrorManager in project tomee by apache.
the class FileHandler method configure.
/**
* Configure from <code>LogManager</code> properties.
*/
private void configure() {
final Timestamp ts = new Timestamp(System.currentTimeMillis());
final String tsString = ts.toString().substring(0, 19);
date = tsString.substring(0, 10);
//allow classes to override
final String className = this.getClass().getName();
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
// Retrieve configuration of logging file name
rotatable = Boolean.parseBoolean(getProperty(className + ".rotatable", "true"));
if (directory == null) {
directory = getProperty(className + ".directory", "logs");
}
if (prefix == null) {
prefix = getProperty(className + ".prefix", "juli.");
}
if (suffix == null) {
suffix = getProperty(className + ".suffix", ".log");
}
final String sBufferSize = getProperty(className + ".bufferSize", String.valueOf(bufferSize));
try {
bufferSize = Integer.parseInt(sBufferSize);
} catch (final NumberFormatException ignore) {
//no op
}
// Get encoding for the logging file
final String encoding = getProperty(className + ".encoding", null);
if (encoding != null && encoding.length() > 0) {
try {
setEncoding(encoding);
} catch (final UnsupportedEncodingException ex) {
// Ignore
}
}
// Get logging level for the handler
setLevel(Level.parse(getProperty(className + ".level", String.valueOf(Level.ALL))));
// Get filter configuration
final String filterName = getProperty(className + ".filter", null);
if (filterName != null) {
try {
setFilter((Filter) cl.loadClass(filterName).newInstance());
} catch (final Exception e) {
// Ignore
}
}
// Set formatter
final String formatterName = getProperty(className + ".formatter", null);
if (formatterName != null) {
try {
setFormatter((Formatter) cl.loadClass(formatterName).newInstance());
} catch (final Exception e) {
// Ignore and fallback to defaults
setFormatter(new SimpleFormatter());
}
} else {
setFormatter(new SimpleFormatter());
}
// Set error manager
setErrorManager(new ErrorManager());
}
Aggregations