title: How to save all console output to file in R?
body: <p>I want to redirect <strong>all</strong> console text to a file. Here is what I tried:</p>
  
  <pre><code>&gt; sink("test.log", type=c("output", "message"))
  &gt; a &lt;- "a"
  &gt; a
  &gt; How come I do not see this in log
  Error: unexpected symbol in "How come"
  </code></pre>
  
  <p>Here is what I got in test.log:</p>
  
  <pre><code>[1] "a"
  </code></pre>
  
  <p>Here is what I want in test.log:</p>
  
  <pre><code>&gt; a &lt;- "a"
  &gt; a
  [1] "a"
  &gt; How come I do not see this in log
  Error: unexpected symbol in "How come"
  </code></pre>
  
  <p>What am I doing wrong? Thanks!</p>