Answers.Body: <p>You usually define a log file like below, and redirect the stdout and/or stderr to it. Stdout is <code>&gt;</code>, stderr is <code>2&gt;</code> and both of them combined is <code>&amp;&gt;</code>.</p>
  <pre><code>rule parse:
      input:
          sequences = rules.join_downloads.output
      output:
          sequences = &quot;data/sequences.fasta&quot;
      log:
          my_output/my_log.log
      shell:
          &quot;&quot;&quot;
          augur parse 2&gt; {log}
          &quot;&quot;&quot;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-12T17:41:49.467Z
Answers.LastActivityDate: 2021-07-12T17:41:49.467Z
Answers.UserDisplayName: Wouter De Coster
Body: <p>I'm wondering how Snakemake deals with output to <code>stdout</code> and <code>stderr</code> that is generated when running a rule with a <code>shell:</code> command.</p>
  <p>I ran the following rule and only got informed that there was a non-zero exit code. However, I did not get a stack trace. To get access to the stack trace I had to run the shell command manually:</p>
  <pre class="lang-yaml prettyprint-override"><code># Shortened for clarity
  rule parse:
      input:
          sequences = rules.join_downloads.output
      output:
          sequences = &quot;data/sequences.fasta&quot;
      shell:
          &quot;&quot;&quot;
          augur parse
          &quot;&quot;&quot;
  </code></pre>
  <p>Why is that? And can I somehow make Snakemake output more detailed information when something goes wrong to help with debugging?</p>
  
Tags: <snakemake>
Title: Where does Snakemake send output that's generated by shell commands?
ThreadText: # Where does Snakemake send output that's generated by shell commands?
  
  (Asked by: username_0 on 2021-07-12)
  
  I'm wondering how Snakemake deals with output to `stdout` and `stderr` that is generated when running a rule with a `shell:` command.
  
  I ran the following rule and only got informed that there was a non-zero exit code. However, I did not get a stack trace. To get access to the stack trace I had to run the shell command manually:
  
  ```yaml
  # Shortened for clarity
  rule parse:
      input:
          sequences = rules.join_downloads.output
      output:
          sequences = "data/sequences.fasta"
      shell:
          """
          augur parse
          """
  
  ```
  
  Why is that? And can I somehow make Snakemake output more detailed information when something goes wrong to help with debugging?
  
  **Tags:** snakemake
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-07-12. Score: 1
  
  You usually define a log file like below, and redirect the stdout and/or stderr to it. Stdout is `>`, stderr is `2>` and both of them combined is `&>`.
  
  ```
  rule parse:
      input:
          sequences = rules.join_downloads.output
      output:
          sequences = "data/sequences.fasta"
      log:
          my_output/my_log.log
      shell:
          """
          augur parse 2> {log}
          """
  
  ```
  
  
  ---
  
  