{"id":25,"date":"2011-05-19T10:09:22","date_gmt":"2011-05-19T15:09:22","guid":{"rendered":"https:\/\/www.falatic.com\/?p=25"},"modified":"2011-05-19T10:10:49","modified_gmt":"2011-05-19T15:10:49","slug":"process-output-logging","status":"publish","type":"post","link":"https:\/\/www.falatic.com\/index.php\/25\/process-output-logging","title":{"rendered":"Process Output Logging in Linux and Windows"},"content":{"rendered":"<p>As I was updating <a href=\"http:\/\/cygwin.wikia.com\/wiki\/How_to_install_a_newer_version_of_GCC\" target=\"_blank\">this Wikia page<\/a>, I added a section about how to create a simple logfile. I thought it&#8217;d be useful to expand upon the subject here.<\/p>\n<p>Sometimes you want a raw log of whatever happens during a process, whether it&#8217;s coming in via STDERR or STDOUT (usually so you can see the warning or error in the context of the rest of the output). A little redirection and judicious use of &#8220;tee&#8221; will accomplish this. You may not know you wanted a log at all until you spent 5 hours running a process and an error occurred 20,000 lines back. Here&#8217;s a quick and easy way to log that output on the off-chance you&#8217;ll need it later!<\/p>\n<p><strong>Simple logging for bash (Linux or Cygwin) <em>or<\/em> a Windows command prompt <\/strong>(assumes you have &#8220;tee&#8221; installed somewhere in your path, e.g., via <a href=\"http:\/\/www.cygwin.com\/\" target=\"_blank\">Cygwin<\/a>). The &#8220;2&gt;&amp;1&#8221; part redirects STDERR to STDOUT prior to piping STDOUT to &#8220;tee&#8221;:<\/p>\n<pre>MyUtil -arg1 A -arg2 B 2&gt;&amp;1 | tee mylogfile.log<\/pre>\n<p><strong>Simple logging f<\/strong><strong>or csh\/tcsh (Linux or Cygwin)<\/strong>. The |&amp; forces STDERR to be piped to &#8220;tee&#8221; alone with the usual STDOUT:<\/p>\n<pre>MyUtil -arg1 A -arg2 B      |&amp; tee mylogfile.log<\/pre>\n<p><strong>Note: <\/strong>non-interactive processes are far more amenable to this&#8230; if manual input is expected  you probably won&#8217;t see the prompt (since tee won&#8217;t flush its buffer  until EOF or a newline, at a minimum (it may buffer MANY lines before  displaying them). If you know when it&#8217;ll occur you CAN enter the data at the appropriate time (or press return or what have you). This is a quick and dirty way to log something you&#8217;d rather not dig into to instrument.<\/p>\n<!-- wpsso rrssb get buttons: buttons on archive option not enabled -->\n","protected":false},"excerpt":{"rendered":"<p>As I was updating this Wikia page, I added a section about how to create a simple logfile. I thought it&#8217;d be useful to expand upon the subject here. Sometimes <a href=\"https:\/\/www.falatic.com\/index.php\/25\/process-output-logging\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[1],"tags":[37,41,40,38,31,42,34,36,35,39,43,117],"class_list":["entry","author-marty","post-25","post","type-post","status-publish","format-standard","category-uncategorized","tag-bash","tag-cmd","tag-command","tag-csh","tag-cygwin","tag-linux","tag-logging","tag-stderr","tag-stdout","tag-tcsh","tag-tee","tag-windows"],"_links":{"self":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/posts\/25","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":0,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/posts\/25\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/media?parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/categories?post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.falatic.com\/index.php\/wp-json\/wp\/v2\/tags?post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}