{"id":1038,"date":"2026-09-02T22:37:25","date_gmt":"2026-09-02T22:37:25","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=1038"},"modified":"2026-09-02T22:37:25","modified_gmt":"2026-09-02T22:37:25","slug":"vps-log-management-journald-logrotate-setup-guide","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/","title":{"rendered":"VPS Log Management with journald and logrotate: Setup Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Every service on a VPS generates logs \u2014 Nginx access logs, MySQL slow queries, SSH authentication attempts, kernel messages, and application output. Without a management strategy, these logs silently consume disk space until they fill your partition, crash your services, and turn a routine maintenance problem into an emergency. This guide covers configuring <code>journald<\/code> and <code>logrotate<\/code> to control log growth, retain useful history, and keep your VPS running smoothly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Log Management Matters on a VPS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A VPS typically has limited disk space \u2014 often 20 GB to 80 GB for entry-level plans. Logs are the silent culprit behind &#8220;No space left on device&#8221; errors. Uncontrolled logging can fill a 20 GB root partition in weeks, especially if you run a busy web server or database. Beyond storage, older logs help you diagnose incidents, detect security breaches, and tune performance \u2014 but only if they are rotated and archived instead of deleted or overwritten.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For more on performance tuning on a VPS, <a href=\"https:\/\/virtualserversvps.com\/blog\/category\/performance-optimization\/\">browse our performance optimization guides<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding journald: Systemd&#8217;s Logging Daemon<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Modern Linux distributions use <code>systemd-journald<\/code> to collect and store log entries from the kernel, systemd units, and services. Unlike traditional syslog, journald stores logs in a structured binary format with metadata (priority, facility, PID, boot ID). This makes filtering and querying more powerful.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Key journald Configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The configuration file is <code>\/etc\/systemd\/journald.conf<\/code>. These are the most important settings for a VPS:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Default<\/th><th>VPS Recommendation<\/th><th>Notes<\/th><\/tr><\/thead><tbody><tr><td><code>SystemMaxUse<\/code><\/td><td>10% of partition<\/td><td><code>500M<\/code><\/td><td>Max disk space for journal<\/td><\/tr><tr><td><code>MaxRetentionSec<\/code><\/td><td>Unlimited<\/td><td><code>2week<\/code><\/td><td>Auto-delete entries older than this<\/td><\/tr><tr><td><code>RuntimeMaxUse<\/code><\/td><td>10% of \/run<\/td><td><code>50M<\/code><\/td><td>Max in-memory journal<\/td><\/tr><tr><td><code>ForwardToSyslog<\/code><\/td><td>yes<\/td><td><code>no<\/code><\/td><td>Disable to avoid duplicate logs<\/td><\/tr><tr><td><code>Compress<\/code><\/td><td>yes<\/td><td><code>yes<\/code><\/td><td>Keep compression enabled<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code># Example \/etc\/systemd\/journald.conf for a VPS\n[Journal]\nSystemMaxUse=500M\nMaxRetentionSec=2week\nRuntimeMaxUse=50M\nForwardToSyslog=no\nCompress=yes<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After editing, restart journald: <code>sudo systemctl restart systemd-journald<\/code>. Verify the limit with <code>journalctl --disk-usage<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Querying Logs with journalctl<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Journalctl is the command-line interface for reading journald logs. These are the most useful queries on a VPS:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Last 50 lines (like tail)\njournalctl -n 50\n\n# Follow new entries (like tail -f)\njournalctl -f\n\n# Logs from last boot\njournalctl -b -1\n\n# Logs for a specific unit\njournalctl -u nginx.service\n\n# Logs from the last hour\njournalctl --since \"1 hour ago\"\n\n# Logs by priority (0=emerg, 2=crit, 3=err)\njournalctl -p err -b\n\n# Export logs to text for analysis\njournalctl -u nginx.service --since \"2025-01-01\" --until \"2025-01-02\" &gt; nginx-jan1.log<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These queries are your first line of defense when debugging a VPS issue. Filtering by unit and priority reduces noise significantly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring logrotate for Traditional Log Files<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Many applications still write to traditional text log files (Nginx, Apache, MySQL, custom scripts). Logrotate handles rotation, compression, and deletion of these files based on policies you define.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The main configuration file is <code>\/etc\/logrotate.conf<\/code>, and service-specific overrides go in <code>\/etc\/logrotate.d\/<\/code>. Here is a practical VPS configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \/etc\/logrotate.conf - global defaults\nweekly\nrotate 4\ncreate\ncompress\ndelaycompress\nmissingok\nnotifempty\n\n# Include custom configs\ninclude \/etc\/logrotate.d<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Nginx Log Rotation Example<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \/etc\/logrotate.d\/nginx\n\/var\/log\/nginx\/*.log {\n    daily\n    rotate 14\n    compress\n    delaycompress\n    missingok\n    notifempty\n    create 0640 www-data adm\n    sharedscripts\n    postrotate\n        if [ -f \/var\/run\/nginx.pid ]; then\n            kill -USR1 $(cat \/var\/run\/nginx.pid)\n        fi\n    endscript\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This rotates Nginx logs daily, keeps 14 days of history, compresses older logs, and sends the USR1 signal to Nginx so it opens new log files without dropping connections.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">MySQL Slow Query Log Rotation<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \/etc\/logrotate.d\/mysql\n\/var\/log\/mysql\/mysql-slow.log {\n    daily\n    rotate 7\n    compress\n    missingok\n    notifempty\n    create 640 mysql adm\n    postrotate\n        mysqladmin flush-logs -u root -pPASSWORD\n    endscript\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Testing and Debugging Logrotate<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Always test logrotate configuration before relying on it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Dry run (no changes)\nsudo logrotate -d \/etc\/logrotate.conf\n\n# Force a rotation\nsudo logrotate -f \/etc\/logrotate.conf\n\n# Check last rotation time\ncat \/var\/lib\/logrotate\/status<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The dry-run mode shows exactly what would happen without touching your files. Use it every time you edit a logrotate config.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Disk Space Monitoring and Alerts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Even with logrotate and journald limits, you should monitor disk usage. Add this simple check to your crontab:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Check disk usage daily and alert if over 80%\n0 6 * * * df -h \/ | awk '\"\"NR==2 &amp;&amp; +5&gt;80 {print \"Disk usage critical: \"+5\"%\"}' | mail -s \"VPS Disk Alert\" you@example.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For a more comprehensive monitoring setup, combine this with Uptime Kuma or Prometheus exporters. See our <a href=\"https:\/\/virtualserversvps.com\/blog\/category\/vps-guides-tutorials\/\">VPS guides and tutorials<\/a> for more maintenance workflows.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">journald vs. syslog: When to Use Each<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On a modern VPS, you do not have to choose one exclusively. Journald is the default log collector, but many legacy tools and third-party monitoring agents expect plain-text log files. A practical hybrid approach:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Let journald collect system logs and unit logs from systemd services.<\/li>\n<li>Use logrotate for application-generated log files (Nginx, MySQL, PHP-FPM, custom scripts).<\/li>\n<li>Forward critical journald logs to a central syslog server if you operate multiple VPS instances.<\/li>\n<li>Set <code>SystemMaxUse<\/code> and <code>MaxRetentionSec<\/code> in journald, and configure logrotate for all text logs.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This combination gives you the query power of journalctl for recent events and the reliable archival of logrotate for long-term storage.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Log management is not exciting, but it is essential. A few minutes spent configuring journald limits and logrotate rules will save you from the &#8220;disk full&#8221; panic that inevitably hits at 2 AM. Set your limits, test your rotation, and monitor your usage \u2014 your future self will thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every service on a VPS generates logs \u2014 Nginx access logs, MySQL slow queries, SSH authentication attempts, kernel messages, and application output. Without a management strategy, these logs silently consume&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1038","post","type-post","status-publish","format-standard","hentry","category-performance-optimization"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>VPS Log Management with journald and logrotate: Setup Guide - Virtual Servers VPS Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"VPS Log Management with journald and logrotate: Setup Guide\" \/>\n<meta property=\"og:description\" content=\"VPS Log Management with journald and logrotate: Setup Guide\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-02T22:37:25+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/\",\"name\":\"VPS Log Management with journald and logrotate: Setup Guide - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-09-02T22:37:25+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"VPS Log Management with journald and logrotate: Setup Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"VPS Log Management with journald and logrotate: Setup Guide - Virtual Servers VPS Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/","og_locale":"en_US","og_type":"article","og_title":"VPS Log Management with journald and logrotate: Setup Guide","og_description":"VPS Log Management with journald and logrotate: Setup Guide","og_url":"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-09-02T22:37:25+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/","url":"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/","name":"VPS Log Management with journald and logrotate: Setup Guide - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-09-02T22:37:25+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/vps-log-management-journald-logrotate-setup-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"VPS Log Management with journald and logrotate: Setup Guide"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1038","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=1038"}],"version-history":[{"count":1,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1038\/revisions"}],"predecessor-version":[{"id":1042,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1038\/revisions\/1042"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}