| 573 | } |
| 574 | |
| 575 | private void configure(InputStream fis, String rootDir) throws IOException { |
| 576 | Properties properties = new Properties(); |
| 577 | properties.load(fis); |
| 578 | |
| 579 | // QDB_LOG_LOG_DIR env variable can be used to override log directory |
| 580 | String logDir = getProperty(properties, "log.dir"); |
| 581 | if (logDir == null) { |
| 582 | if (rootDir != null) { |
| 583 | logDir = Paths.get(rootDir, "log").toAbsolutePath().toString(); |
| 584 | } else { |
| 585 | logDir = "."; |
| 586 | } |
| 587 | } |
| 588 | boolean usesLogDirVar = false; |
| 589 | for (String n : properties.stringPropertyNames()) { |
| 590 | String value = getProperty(properties, n); |
| 591 | if (value.contains(LOG_DIR_VAR)) { |
| 592 | usesLogDirVar = true; |
| 593 | value = value.replace(LOG_DIR_VAR, logDir); |
| 594 | properties.put(n, value); |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | if (usesLogDirVar) { |
| 599 | File logDirFile = new File(logDir); |
| 600 | if (!logDirFile.exists() && logDirFile.mkdirs()) { |
| 601 | System.err.printf("Created log directory: %s%n", logDir); |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | configureFromProperties(properties); |
| 606 | } |
| 607 | |
| 608 | private void configureDefaultWriter() { |
| 609 | int level = DEFAULT_LOG_LEVEL; |