logback get ref appender programmatically
<p>Having this logback file configuration</p>

<pre><code>&lt;appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
    &lt;file&gt;build/test.log&lt;/file&gt;
    &lt;append&gt;false&lt;/append&gt;
    &lt;encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder"&gt;
        &lt;providers&gt;
            &lt;timestamp/&gt;
            &lt;arguments/&gt;
            &lt;version/&gt;
            &lt;loggerName/&gt;
            &lt;logLevel/&gt;
            &lt;logLevelValue/&gt;
            &lt;stackTrace/&gt;
            &lt;message/&gt;
            &lt;threadName/&gt;
            &lt;provider class="com.tesco.utils.CorrelatedProvider"/&gt;
        &lt;/providers&gt;
    &lt;/encoder&gt;
    &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
        &lt;fileNamePattern&gt;build/test_%d{yyyy-MM-dd}.%i.log&lt;/fileNamePattern&gt;
        &lt;timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"&gt;
            &lt;maxFileSize&gt;1MB&lt;/maxFileSize&gt;
        &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
        &lt;!-- keep 30 days' worth of history --&gt;
        &lt;maxHistory&gt;30&lt;/maxHistory&gt;
    &lt;/rollingPolicy&gt;
&lt;/appender&gt;

&lt;appender name="ASYNC_FILE" class="ch.qos.logback.classic.AsyncAppender"&gt;
    &lt;appender-ref ref="FILE"/&gt;
&lt;/appender&gt;

&lt;root level="INFO"&gt;
    &lt;appender-ref ref="ASYNC_FILE"/&gt;
&lt;/root&gt;
</code></pre>

<p>I´m trying to get the appender FILE but for now the only one that I can get is ASYNC_FILE. How can I get the ref appender of ASYNC_FILE?. 
Here the code that I did so far:</p>

<pre><code>  RollingFileAppender&lt;ILoggingEvent&gt; rollingFileAppender = new RollingFileAppender&lt;&gt;();
        LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
        for (Logger logger : context.getLoggerList()) {
            for (Iterator&lt;Appender&lt;ILoggingEvent&gt;&gt; index = logger.iteratorForAppenders(); index.hasNext();) {
                Appender&lt;ILoggingEvent&gt; appender = index.next();
                if(appender.getName().equals("ASYNC_FILE")){
                    //How can I get the reference appender FILE?
                    rollingFileAppender = (RollingFileAppender&lt;ILoggingEvent&gt;) appender;
                }
            }
        }
</code></pre>

<p><strong>SOLUTION</strong> 
I Forgot to cast the appender as AsyncAppender that´s why the subAppenders were not exposed</p>

<pre><code>   RollingFileAppender&lt;ILoggingEvent&gt; rollingFileAppender = new RollingFileAppender&lt;&gt;();
        LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
        for (Logger logger : context.getLoggerList()) {
            for (Iterator&lt;Appender&lt;ILoggingEvent&gt;&gt; index = logger.iteratorForAppenders(); index.hasNext();) {
                Appender&lt;ILoggingEvent&gt; appender = index.next();
                if(appender.getName().equals("ASYNC_TIMING_LOG")){
                    AsyncAppender asyncAppender = (AsyncAppender) appender;
                    rollingFileAppender = (RollingFileAppender&lt;ILoggingEvent&gt;) asyncAppender.getAppender("TIMING_LOG");
                }
            }
        }
</code></pre>