title: Redirect batch stderr to file
body: <p>I have a batch file that executes a java application.  I'm trying to modify it so that whenever an exception occurs, it'll write the STDERR out to a file.</p>
  
  <p>It looks something like this:</p>
  
  <pre><code>start java something.jar method %1 %2 2&gt;&gt; log.txt
  </code></pre>
  
  <p>Is there a way I can write the arguments %1 and %2 to the log.txt file as well?  I don't want to write it to the log file everytime this batch file gets called, only when an exception occurs.</p>
  
  <p>I tried searching for a way to redirect STDERR into a variable, but I couldn't figure it out.  Ideally I'd like the log file to look something like:</p>
  
  <pre><code>Batch file called with parameters:
  - "first arg"
  - "second arg"
  Exception: 
  java.io.exception etc...
  
  ------------------------------------
  
  Batch file called with parameters:
  - "first arg"
  - "second arg"
  Exception: 
  java.io.exception etc...
  </code></pre>