pythonshellloggingsnakemakeonerror

Logging Snakemake's own console output - how to change what file Snakemake logs to?


I'm trying to save Snakemake's own console output (not the logs generated by the individual jobs) to an arbitrary file while still having it written to stdout/stderr. (Unfortunately, my setup means I can't just use tee.)
It looks to me like Snakemake should provide that functionality, given it saves the log output to a default location. However, looking through the documentation, I couldn't find a parameter to easily change the output location for the log. From the code of snakemake.logging, I'm getting the impression the logfile's parent directory may be hardcoded, with the file just getting a timestamped name.

Is there some bleedingly obvious way to configure what file Snakemake logs to that I'm overlooking?


Solution

  • The file name/path is hardcoded in setup_logfile.

    It's a hack, but one option is to copy the log file to the desired location using onsuccess/onerror (note that there is no oncompletion, so the log copying should probably apply to both cases):

    onsuccess:
        shell("cp -v {log} some_path_for_log_copy.log")
    
    onerror:
        shell("cp -v {log} some_path_for_log_copy.log")