How and where logs are stored on a server
Published on 2026-09-12 by frfrand
Where each thing is searched, what changed with journald, why a log without rotation fills the disk, and the commands that solve most searches.

Short answer: on modern Linux, logs are in two places: the systemd journal (binary, queried with journalctl) and the text files in /var/log, where services like nginx write theirs. To prevent them from filling up the disk, logrotate rotates the text files and journald.conf sets the journal limit.
When something fails, the answer is almost always already written somewhere. The problem is knowing where.
Two systems coexisting
On modern Linux there are two places where logs go, and it is useful to understand the difference.
journald (from systemd) stores them in an indexed binary format, with metadata: which service each line comes from, which user, which process, with what priority. It is queried with journalctl.
The text files in /var/log still exist. Many services (nginx, for example) write their own files directly, and on many distributions rsyslog copies part of the journal to files for compatibility.
That duplication explains a frequent confusion: the same message can appear on both sides.
Commands worth memorizing
For a service:
journalctl -u miapp -f # live journalctl -u miapp --since "1 hour ago" journalctl -u miapp -n 200 # the last 200 lines
For system errors:
journalctl -p err -S today
The -p option filters by priority, using the classic syslog scale: 0 emergency, 3 error, 4 warning, 6 informational. Filtering by err cuts out the noise and shows what matters.
And for text files:
tail -f /var/log/nginx/error.log grep -i "timeout" /var/log/nginx/error.log | tail -50
A shortcut that saves time
If nginx returns 502, the problem is almost never in nginx: it means it couldn't talk to your application (it's not running, listening on another port, or returned an invalid response). The nginx error tells you which one it was (for example, connect() failed (111: Connection refused)), and the root cause is in your application's log.
A 504 is different: nginx did reach your application, but it didn't respond within the time nginx waits.
Knowing that difference saves many searches in the wrong file.
Rotation, and why the disk fills up
A log grows indefinitely if no one cuts it. Rotation takes care of that: it renames the file, starts a new one, compresses old ones, and deletes those that exceed retention.
For text files, logrotate does it, with its configuration in /etc/logrotate.d/. Each service leaves its file there.
For the journal, the limit is configured in /etc/systemd/journald.conf:
SystemMaxUse=500M
Without that limit, the persistent journal can grow up to its default cap: 10% of the filesystem, with a maximum of 4 GB.
And the command you'll want the day the disk fills up:
journalctl --disk-usage journalctl --vacuum-time=7d # deletes anything older than 7 days
Two details that bite
A rotated log while a process has it open. If rotation renames the file and the process keeps writing to the old descriptor, space is not freed and new lines go to a nameless file. That's why rotation configuration includes notifying the process to reopen its files. When you see that the disk doesn't free up after rotation, it's usually this.
Container application logs do not go to the journal by default: the container engine captures them. If you don't configure rotation there, those files grow out of control. It's a very common cause of full disks on Docker servers.
What's worth logging
More is not better. A log with everything is as useless as an empty one, because nobody reads it.
Three habits that make logs useful:
- A per-request identifier, appearing in all related lines. It allows reconstructing what happened in a specific case.
- Structured format (JSON) if you're going to process them with tools. Plain text if you're going to read them with your eyes.
- Never sensitive data. Passwords, tokens, and personal data do not go to the log. It's one of the most common ways of leakage, and it almost always happens through a debugging session that was left on.
In ArduMaker, the logs of systemd services, scheduled tasks, and nginx for each domain, and the record of each deployment, can be read from the VPS panel without having to access via SSH to search for them.
Where to look when an API stops responding
If Nginx returns 502, check its logs and then the application service. journalctl -u service-name can show startup errors, missing variables, or problems connecting to PostgreSQL. Correlate event times between components.
On an ArduMaker VPS it is advisable to separate application, proxy, and scheduled job logs, and define how long they are kept. Avoid logging passwords, tokens, or sensitive data in debug responses.
Related: HTTP Errors · What is observability.
Frequently asked questions
Where are the logs of a service on Linux? If it is a systemd service, in the journal: journalctl -u name. If the program writes its own files, like nginx, in /var/log/<program>/.
What is the difference between a 502 and a 504 in nginx? With a 502, nginx could not talk to the application or received something invalid. With a 504, it managed to talk to it, but the response did not arrive in time.
How do I free up space if the journal filled the disk? journalctl --disk-usage shows how much space it occupies and journalctl --vacuum-time=7d (or --vacuum-size=500M) deletes old entries. To prevent it from happening again, set SystemMaxUse in journald.conf.