Capturing diagnostic output from wget in a log file keeps a durable record of downloads, errors, and HTTP responses, which simplifies troubleshooting flaky networks and auditing what was retrieved. Persistent logs also make it easier to compare behavior over time, especially for scheduled downloads, batch jobs, and automated mirrors.
The wget client writes progress information, HTTP headers, and status messages to its diagnostic streams while saving the downloaded payload to files or standard output. Options such as output-file and append-output redirect those diagnostic messages into a plain-text log without changing how the actual data is stored, which allows scripts to parse logs separately from the downloaded content.
Log files can grow quickly and may contain sensitive query strings, cookies, or tokens if those are part of the requested URLs or headers. Choosing an appropriate log location, restricting file permissions, and combining logging with quiet modes reduces terminal noise while retaining enough detail for analysis on systems where wget is available.
Related: How to run wget downloads in the background
Related: How to debug wget connections
Steps to log wget output to a file:
- Open a terminal in the user account that runs the downloads.
$ whoami userRunning wget under a dedicated account simplifies tracking and limits the scope of credentials and files exposed through logging.
- Create a directory under the home folder to store wget log files.
$ mkdir -p ~/logs
Using a dedicated directory such as ~/logs keeps diagnostic files separate from downloaded data and simplifies cleanup or rotation.
- Run wget with the output-file option to log a single download into a fresh file.
$ wget --output-file=~/logs/wget.log https://example.com/file.iso --2025-02-03 09:15:42-- https://example.com/file.iso Resolving example.com (example.com)... 93.184.216.34 Connecting to example.com (example.com)|93.184.216.34|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 10485760 (10M) [application/octet-stream] Saving to: ‘file.iso’ file.iso 100%[=====================>] 10.0M 8.5MB/s in 1.2s 2025-02-03 09:15:44 (8.5 MB/s) - ‘file.iso’ saved [10485760/10485760]
The output-file option overwrites any existing file with the same name, so each invocation that uses it starts with a clean log.
- Use the append-output option when multiple invocations should accumulate entries in the same log file instead of replacing it.
$ wget --append-output=~/logs/wget.log https://example.com/another-file.tar.gz --2025-02-03 09:20:10-- https://example.com/another-file.tar.gz Resolving example.com (example.com)... 93.184.216.34 Connecting to example.com (example.com)|93.184.216.34|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 5242880 (5.0M) [application/x-tar] Saving to: ‘another-file.tar.gz’ another-file.tar.gz 100%[=====================>] 5.0M 6.0MB/s in 0.9s 2025-02-03 09:20:11 (6.0 MB/s) - ‘another-file.tar.gz’ saved [5242880/5242880]
Long-running jobs that use append-output can generate large log files and may record sensitive URLs or headers, so log rotation and restricted permissions are important to prevent disk exhaustion and data exposure.
- Combine logging with quiet mode to suppress progress output on the terminal while still capturing full detail in the log.
$ wget --append-output=~/logs/wget.log --quiet https://example.com/large-file.img
Quiet mode reduces on-screen noise but does not remove information from the log file, which makes it suitable for cron jobs and non-interactive scripts.
- Inspect the log file to confirm that wget activity is being recorded as expected.
$ tail -n 10 ~/logs/wget.log --2025-02-03 09:15:42-- https://example.com/file.iso Resolving example.com (example.com)... 93.184.216.34 Connecting to example.com (example.com)|93.184.216.34|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 10485760 (10M) [application/octet-stream] Saving to: ‘file.iso’ 2025-02-03 09:15:44 (8.5 MB/s) - ‘file.iso’ saved [10485760/10485760] --2025-02-03 09:20:10-- https://example.com/another-file.tar.gz
Recent timestamps, expected URLs, HTTP status values such as 200, and byte counts that match completed downloads indicate that logging for wget is working correctly.
- Periodically archive or rotate the log file when it grows large to keep storage use under control.
$ du -h ~/logs/wget.log 2.4M /home/user/logs/wget.log
Standard tools such as logrotate or a simple policy of truncating logs after inspection help prevent unexpected growth, especially on systems with frequent automated downloads.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.
