How to Make Unrar Generate a Log File
Generating a log file during the extraction process with
unrar allows administrators and developers to audit file
integrity, troubleshoot errors, and track automated unpack jobs. While
the utility includes specialized command-line switches to output errors
directly to a file, standard shell redirection remains the most
comprehensive method for capturing complete operational output. This
guide explains both the native switch methods and command-line
redirection techniques across Linux, macOS, and Windows.
Method 1: Using Native Unrar Switches
The official command-line unrar utility includes
built-in logging flags specifically designed to capture extraction
errors and filenames.
Log Errors Only (-ilog)
To log only errors encountered during extraction (such as corrupt
archives, bad CRCs, or missing volumes), use the -ilog
switch:
unrar x -ilog[error.log] archive.rarNote: In most versions of WinRAR/unrar, you can omit the brackets:
unrar x -ilog=error.log archive.rarLog Extracted File Names
(-log)
If your binary supports the -log switch, you can log all
processed files to a designated text file:
unrar x -log=extraction.log archive.rarMethod 2: Shell Redirection (Recommended)
Because different versions of unrar (such as the
non-free RARLabs version versus the open-source GNU variant) handle
internal switches differently, operating system-level output redirection
is the most reliable way to create a comprehensive log containing both
standard output and error messages.
Linux and macOS (Bash/Zsh)
To redirect both standard output (stdout) and standard error (stderr) to a log file:
unrar x archive.rar > extraction.log 2>&1>writes standard output toextraction.log.2>&1ensures that error messages (stderr) are redirected into the same log file.
To append to an existing log file instead of overwriting it, replace
> with >>:
unrar x archive.rar >> extraction.log 2>&1View Progress and
Log Simultaneously with tee
To monitor the extraction on your screen while simultaneously saving the output to a file:
unrar x archive.rar 2>&1 | tee extraction.logMethod 3: Windows Command Prompt and PowerShell
Windows Command Prompt (CMD)
In CMD, the redirection syntax is identical to Unix-like systems:
unrar.exe x archive.rar > extraction.log 2>&1Windows PowerShell
In PowerShell, use the following syntax to capture all output streams:
unrar.exe x archive.rar *>&1 | Out-File -FilePath extraction.logUseful Flags for Silent and Automated Logging
When integrating unrar into automated scripts or cron
jobs, combining your log command with additional switches creates clean,
non-interactive log files:
-y: Assumes "yes" on all queries (such as overwrite prompts), preventing the process from hanging while waiting for user input.-inul: Suppresses standard console messages, leaving only critical output.-c-: Disables the archive comment display to minimize log bloat.
Example automated extraction command:
unrar x -y archive.rar > /var/log/unrar_job.log 2>&1