{"id":3825,"date":"2016-04-19T12:08:09","date_gmt":"2016-04-19T12:08:09","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3825"},"modified":"2016-04-19T12:08:09","modified_gmt":"2016-04-19T12:08:09","slug":"node-log-files-forever","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/node-log-files-forever\/","title":{"rendered":"Node: log files with Forever"},"content":{"rendered":"<p>&#8220;Forever&#8221; has arguments to set log file output. It&#8217;s important to get the order of the arguments correct (your file goes at the end), because anything after the javascript file name is passed as arguments to your script.<\/p>\n<pre lang=\"bash\">\nnode_modules\/forever\/bin\/forever start \\\n -l \/var\/log\/ssl-search-forever.log \\\n -o \/var\/log\/ssl-search-output.log \\\n -e \/var\/log\/ssl-search-error.log \\\n index.js\n<\/pre>\n<p>You can then watch the output of these, like so:<\/p>\n<pre lang=\"bash\">\ntail -f \/var\/log\/ssl-search-*\n<\/pre>\n<p>You also probably want log rotation &#8211; this is what I&#8217;m using (will update later if I run into problems with it)<\/p>\n<pre>\n\/var\/log\/ssl-search*.log {\n  daily\n  dateext\n  missingok\n  rotate 7\n  compress\n  delaycompress\n  notifempty\n  copytruncate\n}\n<\/pre>\n<p>If you want to control what goes into the access logs, you need to set up morgan correctly (this needs to happen at the beginning of the node app, not at the end):<\/p>\n<pre lang=\"javascript\">\napp.use(require(\"morgan\")(\"combined\"));\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Everything you need to use logging from a node app held together with the duct-tape known as forever<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[345,387,388,389,559],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3825"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3825"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3825\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}