MCPcopy Index your code
hub / github.com/apache/tomcat / configure

Method configure

java/org/apache/juli/FileHandler.java:350–437  ·  view source on GitHub ↗

Configure from LogManager properties.

()

Source from the content-addressed store, hash-verified

348 * Configure from <code>LogManager</code> properties.
349 */
350 private void configure() {
351
352 String className = this.getClass().getName(); // allow classes to override
353
354 ClassLoader cl = ClassLoaderLogManager.getClassLoader();
355
356 // Retrieve configuration of logging file name
357 if (rotatable == null) {
358 rotatable = Boolean.valueOf(getProperty(className + ".rotatable", "true"));
359 }
360 if (directory == null) {
361 directory = getProperty(className + ".directory", "logs");
362 }
363 if (prefix == null) {
364 prefix = getProperty(className + ".prefix", "juli.");
365 }
366 if (suffix == null) {
367 suffix = getProperty(className + ".suffix", ".log");
368 }
369
370 // https://bz.apache.org/bugzilla/show_bug.cgi?id=61232
371 boolean shouldCheckForRedundantSeparator = !rotatable.booleanValue() && !prefix.isEmpty() && !suffix.isEmpty();
372 // assuming separator is just one char, if there are use cases with
373 // more, the notion of separator might be introduced
374 if (shouldCheckForRedundantSeparator && (prefix.charAt(prefix.length() - 1) == suffix.charAt(0))) {
375 suffix = suffix.substring(1);
376 }
377
378 pattern = Pattern
379 .compile("^(" + Pattern.quote(prefix) + ")\\d{4}-\\d{1,2}-\\d{1,2}(" + Pattern.quote(suffix) + ")$");
380
381 if (maxDays == null) {
382 String sMaxDays = getProperty(className + ".maxDays", String.valueOf(DEFAULT_MAX_DAYS));
383 try {
384 maxDays = Integer.valueOf(sMaxDays);
385 } catch (NumberFormatException ignore) {
386 maxDays = Integer.valueOf(DEFAULT_MAX_DAYS);
387 }
388 }
389
390 if (bufferSize == null) {
391 String sBufferSize = getProperty(className + ".bufferSize", String.valueOf(DEFAULT_BUFFER_SIZE));
392 try {
393 bufferSize = Integer.valueOf(sBufferSize);
394 } catch (NumberFormatException ignore) {
395 bufferSize = Integer.valueOf(DEFAULT_BUFFER_SIZE);
396 }
397 }
398
399 // Get encoding for the logging file
400 String encoding = getProperty(className + ".encoding", null);
401 if (encoding != null && !encoding.isEmpty()) {
402 try {
403 setEncoding(encoding);
404 } catch (UnsupportedEncodingException ignore) {
405 // Ignore
406 }
407 }

Callers 1

FileHandlerMethod · 0.95

Calls 15

getClassLoaderMethod · 0.95
getPropertyMethod · 0.95
charAtMethod · 0.80
lengthMethod · 0.80
getNameMethod · 0.65
newInstanceMethod · 0.65
valueOfMethod · 0.45
booleanValueMethod · 0.45
isEmptyMethod · 0.45
compileMethod · 0.45
quoteMethod · 0.45
setEncodingMethod · 0.45

Tested by

no test coverage detected