Configure from LogManager properties.
()
| 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 | } |
no test coverage detected