<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Logging on Documentation</title><link>https://docs.ayshell.dev/tags/logging/</link><description>Recent content in Logging on Documentation</description><generator>Hugo -- 0.147.5</generator><language>en</language><lastBuildDate>Mon, 30 Jun 2025 10:38:19 +0530</lastBuildDate><atom:link href="https://docs.ayshell.dev/tags/logging/index.xml" rel="self" type="application/rss+xml"/><item><title>Linux: Advanced Filtering and Analyzing System Logs with journalctl</title><link>https://docs.ayshell.dev/posts/linux/journald/filters-journalctl/</link><pubDate>Mon, 30 Jun 2025 10:38:19 +0530</pubDate><guid>https://docs.ayshell.dev/posts/linux/journald/filters-journalctl/</guid><description>&lt;h1 id="what-is-journalctl-filters">What is &lt;code>journalctl&lt;/code> Filters?&lt;/h1>
&lt;p>You can use filters with &lt;code>journalctl&lt;/code> to narrow down and control which log entries are displayed. &lt;code>journalctl&lt;/code> supports a wide range of filtering options, both by structured fields and by command-line flags.&lt;/p>
&lt;ul>
&lt;li>Structured Fields: &lt;code>SYSLOG_IDENTIFIER&lt;/code>, &lt;code>_SYSTEMD_UNIT&lt;/code>, &lt;code>_UID&lt;/code>, etc&lt;/li>
&lt;li>Command-Line Fields: &lt;code>--since&lt;/code>, &lt;code>--until&lt;/code>, &lt;code>-u&lt;/code>, &lt;code>-p&lt;/code>, &lt;code>--grep&lt;/code>, etc&lt;/li>
&lt;/ul>
&lt;h2 id="common-journalctl-filters">Common &lt;code>journalctl&lt;/code> Filters&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Filter Type&lt;/th>
&lt;th>Example Command&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>By Time&lt;/td>
&lt;td>&lt;code>journalctl --since &amp;quot;8 hours ago&amp;quot;&lt;/code>&lt;/td>
&lt;td>Shows logs since a specific time&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Service/Unit&lt;/td>
&lt;td>&lt;code>journalctl -u nginx.server&lt;/code>&lt;/td>
&lt;td>Show logs for a specific server/unit&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Priority&lt;/td>
&lt;td>&lt;code>journalctl -p warning&lt;/code>&lt;/td>
&lt;td>Show logs at/above a certain severity&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Field&lt;/td>
&lt;td>&lt;code>journalctl SYSLOG_IDENTIFIER=sudo&lt;/code>&lt;/td>
&lt;td>Show logs where a field matches a value&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Boot&lt;/td>
&lt;td>&lt;code>journalctl -b -1&lt;/code>&lt;/td>
&lt;td>Shows logs from the previous boot&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Keyword&lt;/td>
&lt;td>&lt;code>journalctl --grep &amp;quot;error&amp;quot;&lt;/code>&lt;/td>
&lt;td>Shows logs containing a keyword&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="advanced-journalctl-filters">Advanced &lt;code>journalctl&lt;/code> Filters&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Filter Type&lt;/th>
&lt;th>Example Command&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>By User ID&lt;/td>
&lt;td>&lt;code>journalctl _UID=user_id&lt;/code>&lt;/td>
&lt;td>Filter logs by the user ID of the process that generated them&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Group ID&lt;/td>
&lt;td>&lt;code>journalctl _GID=group_id&lt;/code>&lt;/td>
&lt;td>Filter logs by the group ID of the process that generated them&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Process ID&lt;/td>
&lt;td>&lt;code>journalctl _PID=process_id&lt;/code>&lt;/td>
&lt;td>Filter logs by process ID&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Process name&lt;/td>
&lt;td>&lt;code>journalctl _COMM=nginx&lt;/code>&lt;/td>
&lt;td>Filter by process name (eg. &lt;code>_COMM=nginx&lt;/code>)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Hostname&lt;/td>
&lt;td>&lt;code>journalctl _HOSTNAME=hostname&lt;/code>&lt;/td>
&lt;td>Filter logs by hostname&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Executable Path&lt;/td>
&lt;td>&lt;code>journalctl _EXE=exe_path&lt;/code>&lt;/td>
&lt;td>Filter logs by executable path (eg: &lt;code>/usr/local/bin/hugo&lt;/code>)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Boot Session&lt;/td>
&lt;td>&lt;code>journalctl _BOOT_ID=boot_id&lt;/code>&lt;/td>
&lt;td>Filter logs by a specific boot session&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Audit Session&lt;/td>
&lt;td>&lt;code>journalctl _AUDIT_SESSION=session_id&lt;/code>&lt;/td>
&lt;td>Filter logs by audit session ID&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>By Syslog Facility Code&lt;/td>
&lt;td>&lt;code>journalctl _SYSLOG_FACILITY=facility_number&lt;/code>&lt;/td>
&lt;td>Filter by syslog facility code&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;strong>Alternatively&lt;/strong>, you can find the available filters in &lt;code>journalctl&lt;/code> by using:&lt;/p></description></item><item><title>Linux: Log Analysis and Journals</title><link>https://docs.ayshell.dev/posts/linux/journald/journalctl/</link><pubDate>Sun, 22 Jun 2025 14:15:38 +0530</pubDate><guid>https://docs.ayshell.dev/posts/linux/journald/journalctl/</guid><description>Understanding Linux log locations, using journalctl, analyzing traditional logs, filtering and searching logs with grep, less and time filters.</description></item></channel></rss>