title: How to catch third party console log using log4j
body: <p>I'm using log4j for logging actions in my application. I use following file appender:</p>
  
  <pre><code> private FileAppender getFileAppender(String name) {
    PatternLayout layout = new PatternLayout("%d{ABSOLUTE} %5p %t %c{1}:%M:%L - %m%n");
    StringBuilder filePath = new StringBuilder();
    filePath.append("logs/")
          .append(name)
          .append(".log");
    FileAppender fileAppender = null;
  
    try {
       File file = new File(filePath.toString());
       file.getParentFile().mkdirs();
       file.createNewFile();
  
       fileAppender = new FileAppender(layout, filePath.toString(), true);
       fileAppender.setName("FileAppender");
       fileAppender.setAppend(true);
    } catch (IOException e) {
       LogWrapper.LOG.get(this.getClass().getSimpleName()).trace(e);
    }
  
    return fileAppender;
    }
  </code></pre>
  
  <p>My application uses third party, what logs web services calls into console. Then I run application I see those logs in my console in Intellij Idea, but not on the  generated log file.</p>
  
  <p>How to redirect those logs into the file, generated by File Appender?</p>
  
  <p><em>Update</em>
  The answer is correct, but there is one more third party what use logback with Console Appender, properties looks like:</p>
  
  <pre><code>&lt;configuration status="OFF"&gt;
  &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
      &lt;encoder&gt;
          &lt;pattern&gt;%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
          &lt;/pattern&gt;
      &lt;/encoder&gt;
  &lt;/appender&gt;
  &lt;root level="WARN"&gt;
      &lt;appender-ref ref="STDOUT" /&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p></p>
  
  <p>Because of this catching console output stacks. How could I catch and re-write Logback properties and make it log to file or disable logs at all?</p>