title: No newlines in stacktrace when run from command line?
body: <p>When i run my application from the command line (standard windows 7) the stacktraces put in my log file don't have newlines. </p>
  
  <p>(hmm, i wanted to paste an example, but when i copy the stacktrace from my log in notepad and paste it in my browser, the newlines suddenly appear)</p>
  
  <p>I also tried opening log with editplus editor but no luck either, stacktraces don't have newlines (enters).</p>
  
  <p>My pattern layout is quite standard (log4j2):</p>
  
  <pre><code>&lt;PatternLayout&gt;
  &lt;Pattern&gt;%d [%15.15t] %-5p %-30.30c{3} %10X{username} - %m%n&lt;/Pattern&gt;
  &lt;/PatternLayout&gt;
  </code></pre>
  
  <p>I simply start my application jar (runnable jar)</p>
  
  <pre><code>java -jar myapp.jar
  </code></pre>
  
  <p>When i run my application from eclipse the stacktraces in log do have newlines/enters.</p>
  
  <p>Anybody got an idea where the problem may lie?</p>
  
  <p>[edit]
  The hex of 4 characters, first character on line 1 and last character on line 2.</p>
  
  <pre><code>74 0A 09 61 
  </code></pre>
  
  <p>Which is:</p>
  
  <pre><code>T - something that isn't a newline? - tab? - A
  </code></pre>
  
  <p>[edit] A simple example with no dependencies except log4j2:</p>
  
  <pre><code>import java.net.SocketTimeoutException;
  
  public class App {
      private org.apache.logging.log4j.Logger log= org.apache.logging.log4j.LogManager.getLogger(App.class);
      public App() {  
          log.error("0", new SocketTimeoutException("test"));
          log.debug("starting");
          log.debug("starting2");
          log.debug("starting3");
          log.debug("starting4");
          log.debug("starting5");
          System.exit(1);
      }
  
      public static void main(String[] args) {
          new App();
      }
  }
  </code></pre>
  
  <p>log4j2.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configuration status="WARN"&gt;
      &lt;Appenders&gt;
          &lt;Console name="Console" target="SYSTEM_OUT"&gt;
              &lt;PatternLayout&gt;
                  &lt;Pattern&gt;%d [%15.15t] %-5p %-30.30c{3} %10X{username} - %m%n&lt;/Pattern&gt;
              &lt;/PatternLayout&gt;
          &lt;/Console&gt;
          &lt;RandomAccessFile name="MyFile" fileName="client.log"&gt;
              &lt;PatternLayout&gt;
                  &lt;Pattern&gt;%d [%15.15t] %-5p %-30.30c{3} %10X{username} - %m%n&lt;/Pattern&gt;
              &lt;/PatternLayout&gt;
          &lt;/RandomAccessFile&gt;
      &lt;/Appenders&gt;
      &lt;Loggers&gt;
  
          &lt;Logger name="com.tate.world" level="debug" additivity="false"&gt;
              &lt;AppenderRef ref="Console" /&gt;
              &lt;AppenderRef ref="MyFile" /&gt;
          &lt;/Logger&gt;
  
  
          &lt;Root level="info"&gt;
              &lt;AppenderRef ref="Console" /&gt;
          &lt;/Root&gt;
  
      &lt;/Loggers&gt;
  
  &lt;/Configuration&gt;
  </code></pre>
  
  <p>Create a runnable jar and run it from the command line:</p>
  
  <pre><code>java -jar test.jar
  </code></pre>
  
  <p>Now open the client.log with notepad, the SocketTimeoutException stacktrace has no newlines.</p>
  
  <p>This is my manifest.mf:</p>
  
  <pre><code>Manifest-Version: 1.0
  Class-Path: . app_lib/log4j-api-2.4.1.jar ap
   p_lib/log4j-core-2.4.1.jar
  Main-Class: com.tate.world.test.App
  </code></pre>
  
  <p>(i also tried the latest 2.5)
  How can i get newlines (that show up in notepad) in the stacktrace? </p>
  
  <p>Thanks for reading!</p>
  
  <p>[edit] For something really weird, comment out the:</p>
  
  <pre><code>log.debug("starting2");
  log.debug("starting3");
  log.debug("starting4");
  log.debug("starting5");
  </code></pre>
  
  <p>and run again from command line, now the stacktrace has newlines again!</p>