public static void configureLogback( ServletContext servletContext, File logDirFallback, String vHostName, Logger log ) throws FileNotFoundException, MalformedURLException, IOException {
    log.debug("Reconfiguring Logback!");
    String systemLogDir = System.getProperty(LOG_DIRECTORY_OVERRIDE, System.getProperty(JBOSS_LOG_DIR));
    if (systemLogDir != null) {
      systemLogDir += "/" + vHostName;
    }
    File logDir = FileSystemManager.getWritableDirectoryWithFailovers(systemLogDir,servletContext.getInitParameter(LOG_DIR_INIT_PARAM), logDirFallback.getAbsolutePath());
    if(logDir != null) {
      log.debug("Resetting logback context.");
      URL configFile = servletContext.getResource("/WEB-INF/context-logback.xml");
      log.debug("Configuring logback with file, {}", configFile);
      LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
      try {
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(context);
        context.stop();
        context.reset();  
        context.putProperty("logDir", logDir.getCanonicalPath());
        configurator.doConfigure(configFile);
      } catch (JoranException je) {
        // StatusPrinter will handle this
      } finally {
        context.start();
        log.debug("Done resetting logback.");
      }
      StatusPrinter.printInCaseOfErrorsOrWarnings(context);
    }
  }
public static void configureLogback ( ServletContext servletContext , File logDirFallback , String vHostName , Logger log ) throws FileNotFoundException , MalformedURLException , IOException { log . debug ( "Reconfiguring Logback!" ) ; String systemLogDir = System . getProperty ( LOG_DIRECTORY_OVERRIDE , System . getProperty ( JBOSS_LOG_DIR ) ) ; if ( systemLogDir != null ) { systemLogDir += "/" + vHostName ; } File logDir = FileSystemManager . getWritableDirectoryWithFailovers ( systemLogDir , servletContext . getInitParameter ( LOG_DIR_INIT_PARAM ) , logDirFallback . getAbsolutePath ( ) ) ; if ( logDir != null ) { log . debug ( "Resetting logback context." ) ; URL configFile = servletContext . getResource ( "/WEB-INF/context-logback.xml" ) ; log . debug ( "Configuring logback with file, {}" , configFile ) ; LoggerContext context = ( LoggerContext ) LoggerFactory . getILoggerFactory ( ) ; try { JoranConfigurator configurator = new JoranConfigurator ( ) ; configurator . setContext ( context ) ; context . stop ( ) ; context . reset ( ) ; context . putProperty ( "logDir" , logDir . getCanonicalPath ( ) ) ; configurator . doConfigure ( configFile ) ; } catch ( JoranException je ) { } finally { context . start ( ) ; log . debug ( "Done resetting logback." ) ; } StatusPrinter . printInCaseOfErrorsOrWarnings ( context ) ; } }
<p>Reconfigures the logging context.</p>
<p>The LoggerContext gets configured with "/WEB-INF/context-logback.xml". There is a <code>logDir</code> property set here which is expected to be the directory that the log file is written to.</p>
<p>The <code>logDir</code> property gets set on the LoggerContext with the following logic.</p>
<ul>
<li>{@link LOG_DIR_INIT_PARAM} context parameter will be created and checked if it is writable.</li>
<li>The File object passed in is used as a fall-back if it can be created and written to.</li>
</ul>
@see {@link LoggerContext}
@param servletContext The current servlet context.
@param logDirFallback The fall-back directory to log to.
@param vHostName
@param log
@throws FileNotFoundException Thrown if no logDir can be written to.
@throws MalformedURLException
@throws IOException