<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Monitoring log file updates from console in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700474#M88518</link>
    <description>&lt;P&gt;I'm running JMP on windows. I just googled &lt;EM&gt;tail&lt;/EM&gt; and checked that man page (I have used it with cygwin to monitor logs though).&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2023 05:32:21 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-11-20T05:32:21Z</dc:date>
    <item>
      <title>Monitoring log file updates from console</title>
      <link>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700264#M88500</link>
      <description>&lt;P&gt;With JMP 17.2.0, I'm trying to monitor the output of a JSL log file from a console — (Mac OS Terminal, in this case). &amp;nbsp;I'm using the &lt;FONT face="courier new,courier"&gt;tail&lt;/FONT&gt; command with the &lt;FONT face="courier new,courier"&gt;-f&lt;/FONT&gt; option to live-view the updates whenever the file is written.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$ tail -f log.txt&lt;/PRE&gt;&lt;P&gt;However, the console output never updates when new text is written to the log. &amp;nbsp;The sample JSL below outputs a line of text every second:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open Log();
Clear Log();
For( ii=0, ii&amp;lt;10, ii++,
	Write( "hello, world " || Char( ii ) || "\!n" );
	Save Log( "log.txt" );
	Wait( 1 );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I start the script, then run the &lt;FONT face="courier new,courier"&gt;tail&lt;/FONT&gt; command a few seconds later, I get an expected result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;$ tail -f log.txt
/*:hello, world 0
hello, world 1
hello, world 2
hello, world 3

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But subsequent JSL log messages are not picked up by the &lt;FONT face="courier new,courier"&gt;tail&lt;/FONT&gt; command. &amp;nbsp;If I &lt;FONT face="courier new,courier"&gt;Ctrl-C&lt;/FONT&gt; out, then re-run &lt;FONT face="courier new,courier"&gt;tail&lt;/FONT&gt;, I properly get everything output to the log file at that point. &amp;nbsp;But the output never again updates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts as to why this doesn't work? &amp;nbsp;Or is there maybe another way to manage a log file where this would work as expected?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Nov 2023 02:11:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700264#M88500</guid>
      <dc:creator>SteveTerry</dc:creator>
      <dc:date>2023-11-18T02:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Monitoring log file updates from console</title>
      <link>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700286#M88502</link>
      <description>&lt;P&gt;Using "powershell version of tail" seems to work fine (this won't run unless the file exists first)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Get-Content -Path "&amp;lt;logfilepath&amp;gt;" -Wait&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/4426442/unix-tail-equivalent-command-in-windows-powershell" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/4426442/unix-tail-equivalent-command-in-windows-powershell&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did write the log with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

For(i = 1, i &amp;lt;= 30, i++,
	Show(i);
	wait(1);
	Save Log("$TEMP/jmplog/log.txt");
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could manually check that the log file is being updated as you think it is and if that is the case, then start figuring out what is wrong with tail. Could save log be for example recreating the file every time and tail drops the live tracking because of that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually when I write logs from JMP I use &lt;A href="https://www.jmp.com/support/help/en/17.2/#page/jmp/file-functions.shtml?os=win&amp;amp;source=application#ww4964116" target="_self"&gt;Save Text File()&lt;/A&gt; . First create the file with headers (if I have those) and then use mode("append") to add new lines. Only if I wanted to get the whole log content I did use Save Log() (for example saving log when code had errors). &lt;A href="https://www.jmp.com/support/help/en/17.2/#page/jmp/programming-functions.shtml?os=win&amp;amp;source=application#ww5014386" target="_blank" rel="noopener"&gt;Get Log()&lt;/A&gt; can also be useful sometimes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Maybe changing -f to -F could help? &lt;A href="https://man7.org/linux/man-pages/man1/tail.1.html" target="_blank"&gt;https://man7.org/linux/man-pages/man1/tail.1.html&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;       -f, --follow[={name|descriptor}]
              output appended data as the file grows;
       -F     same as --follow=name --retry
       --retry
              keep trying to open a file if it is inaccessible&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Nov 2023 06:12:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700286#M88502</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-11-18T06:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Monitoring log file updates from console</title>
      <link>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700323#M88504</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/17813"&gt;@SteveTerry&lt;/a&gt;&amp;nbsp;If it is because JMP is replacing the file and tail can't latch on to the new file (seems likely) then (pseudo code, approximately) something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;xxx = get log text();
clear log(); // so each chunk is appended only once
savetextfile("log.txt", xxx, mode("append") );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;alternatively, you might use watch, something like&lt;/P&gt;
&lt;PRE&gt;watch tail log.txt&lt;/PRE&gt;
&lt;P&gt;to rerun the tail command every few seconds. Easier, but not as efficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Nov 2023 12:28:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700323#M88504</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-11-18T12:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Monitoring log file updates from console</title>
      <link>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700345#M88509</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;,&amp;nbsp;the &lt;FONT face="courier new,courier"&gt;-F&lt;/FONT&gt; option is what got it to work. &amp;nbsp;Not sure why I didn't pick up on that in the &lt;FONT face="courier new,courier"&gt;man&lt;/FONT&gt; page — probably because I've been using &lt;FONT face="courier new,courier"&gt;-f&lt;/FONT&gt; for decades and wasn't keen on thinking outside the box. &amp;nbsp;Fyi, the &lt;FONT face="courier new,courier"&gt;--retry&lt;/FONT&gt; option doesn't exist on Mac; &amp;nbsp;it kinda looks like you're using JMP in a Linux environment?? &amp;nbsp;I'd like to know more about that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use &lt;FONT face="courier new,courier"&gt;Save Text File()&lt;/FONT&gt; iteratively quite a bit for building JSL scripts dynamically, but I don't think that's appropriate here since it doesn't capture stuff sent to the log, e.g., &lt;FONT face="courier new,courier"&gt;Write()&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;Show()&lt;/FONT&gt;, so it would be double work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;,&amp;nbsp;thanks for your suggestions. &amp;nbsp;Fyi, &lt;FONT face="courier new,courier"&gt;watch&lt;/FONT&gt; doesn't appear on Mac (for base installs anyway — perhaps I could manually install it), though I see in on Ubuntu. &amp;nbsp;Oh my, are you somehow combining JMP with Linux also?? &amp;nbsp;;–)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you both indicate, it does appear that &lt;FONT face="courier new,courier"&gt;Save Log()&lt;/FONT&gt; is re-writing the file in a manner that gives it a new inode, which &lt;FONT face="courier new,courier"&gt;tail -f&lt;/FONT&gt; loses. &amp;nbsp;This seems very inefficient. &amp;nbsp;I can imagine how this might be useful in some circumstances where lots of log buffer manipulation is going on such as periodic clearing. &amp;nbsp;But I think, for most applications, It would be far preferable if there existed a buffer flush mechanism of the log to a pre-assigned file. &amp;nbsp;My code actually issues&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Save Log()&lt;/FONT&gt; commands very frequently in order to capture recent activity in case of a runtime fault (so I can identify what it was last doing before the fault). &amp;nbsp;It sounds now like that's creating a lot of disk thrashing. &amp;nbsp;Is this possibly a new feature I may want to suggest?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Nov 2023 18:44:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700345#M88509</guid>
      <dc:creator>SteveTerry</dc:creator>
      <dc:date>2023-11-18T18:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Monitoring log file updates from console</title>
      <link>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700346#M88510</link>
      <description>&lt;P&gt;I run JMP on windows running in a VirtualBox under Linux. &lt;LI-MESSAGE title="Can JSL talk to Linux?" uid="33689" url="https://community.jmp.com/t5/Uncharted/Can-JSL-talk-to-Linux/m-p/33689#U33689" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp; for example.&lt;/P&gt;
&lt;P&gt;I think the wish you might want to add is for JMP to also be able to write a disk file log, in parallel with the log window, possibly flushing the output every line.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Nov 2023 19:04:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700346#M88510</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-11-18T19:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Monitoring log file updates from console</title>
      <link>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700474#M88518</link>
      <description>&lt;P&gt;I'm running JMP on windows. I just googled &lt;EM&gt;tail&lt;/EM&gt; and checked that man page (I have used it with cygwin to monitor logs though).&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 05:32:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/700474#M88518</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-11-20T05:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: Monitoring log file updates from console</title>
      <link>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/701114#M88564</link>
      <description>&lt;P&gt;Added this feature to Wish List in case anyone would like to comment on or up-vote it.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/JMP-Wish-List/Provide-option-to-write-log-file-to-disk-in-parallel-with-the/idi-p/701103" target="_blank"&gt;https://community.jmp.com/t5/JMP-Wish-List/Provide-option-to-write-log-file-to-disk-in-parallel-with-the/idi-p/701103&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 19:21:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Monitoring-log-file-updates-from-console/m-p/701114#M88564</guid>
      <dc:creator>SteveTerry</dc:creator>
      <dc:date>2023-11-20T19:21:15Z</dc:date>
    </item>
  </channel>
</rss>

