예제 #1
0
  /** @return the nested diagnostic context string for this step's log file */
  @SuppressWarnings("unchecked")
  private String getNestedDiagnosticContext() {
    Step unProxiedStep = (Step) ProxyUtils.getTargetIfProxied(step);
    Class stepClass = unProxiedStep.getClass();
    ModuleService module =
        SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(stepClass);

    String nestedDiagnosticContext =
        StringUtils.substringAfter(module.getModuleConfiguration().getNamespaceCode(), "-")
                .toLowerCase()
            + File.separator
            + step.getName()
            + "-"
            + dateTimeService.toDateTimeStringForFilename(dateTimeService.getCurrentDate());

    return nestedDiagnosticContext;
  }
예제 #2
0
  /** Add a new appender and context to the NDC for this execution of the step */
  private void setupNDCLogging() {
    String nestedDiagnosticContext = getNestedDiagnosticContext();
    logFileName = getLogFileName(nestedDiagnosticContext);

    ndcAppender = null;
    ndcSet = false;
    try {
      ndcAppender = new FileAppender(BatchLogger.getLogFileAppenderLayout(), logFileName);
      ndcAppender.addFilter(new NDCFilter(nestedDiagnosticContext));
      Logger.getRootLogger().addAppender(ndcAppender);
      NDC.push(nestedDiagnosticContext);
      ndcSet = true;
    } catch (Exception ex) {
      LOG.warn("Could not initialize custom logging for step: " + step.getName(), ex);
    }
  }