{"id":5059,"date":"2024-03-19T14:24:49","date_gmt":"2024-03-19T21:24:49","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=5059"},"modified":"2024-03-19T14:24:51","modified_gmt":"2024-03-19T21:24:51","slug":"how-to-log-messages-from-a-remote-host-to-a-specific-file-in-rsyslog","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=5059","title":{"rendered":"How to Log Messages from a Remote Host to a Specific File in Rsyslog"},"content":{"rendered":"\n<p>Sometimes, you may want to save the log from a remote server to a specific file instead of \/var\/log\/messages. you can set up log forwarding later that won&#8217;t include lots of junk.<\/p>\n\n\n\n<p><strong>Step 1<\/strong><\/p>\n\n\n\n<p>Create a new conf file in \/etc\/rsyslog.d with below two lines, for example. we are going to save the log messages from a host called DarkTrace2LogScale to a log file \/var\/log\/darktrace.log. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if $fromhost == 'DarkTrace2LogScale' then \/var\/log\/darktrace.log\n&amp; stop<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"808\" height=\"72\" src=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image.png\" alt=\"\" class=\"wp-image-5060\" srcset=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image.png 808w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-300x27.png 300w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-768x68.png 768w\" sizes=\"(max-width: 808px) 100vw, 808px\" \/><\/figure>\n\n\n\n<p><strong>Step 2<\/strong><\/p>\n\n\n\n<p>Create a new log file for this purpose and then restart the rsyslog service.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"520\" height=\"51\" src=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-1.png\" alt=\"\" class=\"wp-image-5061\" srcset=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-1.png 520w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-1-300x29.png 300w\" sizes=\"(max-width: 520px) 100vw, 520px\" \/><\/figure>\n\n\n\n<p><strong>Step 3<\/strong><\/p>\n\n\n\n<p>Verify the configuration is actually working.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"224\" src=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-2-1024x224.png\" alt=\"\" class=\"wp-image-5062\" srcset=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-2-1024x224.png 1024w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-2-300x66.png 300w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-2-768x168.png 768w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-2-1536x337.png 1536w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/image-2.png 1894w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes, you may want to save the log from a remote server to a specific file instead of \/var\/log\/messages. you can set up log forwarding later that won&#8217;t include lots of junk. Step 1 Create a new conf file in \/etc\/rsyslog.d with below two lines, for example. we are going to save the log messages <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=5059\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[262,5],"tags":[1771,1772],"class_list":["post-5059","post","type-post","status-publish","format-standard","hentry","category-centos","category-linux","tag-how-to-save-log-messages-to-a-specific-file-in-rsyslog","tag-rsyslog-log-messages-to-a-specific-file"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/5059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5059"}],"version-history":[{"count":1,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/5059\/revisions"}],"predecessor-version":[{"id":5063,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/5059\/revisions\/5063"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}