<?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 How to create different log files per process id or session in Developers</title>
    <link>https://communities.sas.com/t5/Developers/How-to-create-different-log-files-per-process-id-or-session/m-p/769189#M6063</link>
    <description>&lt;P&gt;How to create a log file per session&amp;nbsp;with below command with&amp;nbsp;&lt;SPAN&gt;&amp;amp;sysjobid&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let Log_file_name =%sysfunc(compress(%scan(&amp;amp;_program,-1,/)_&amp;amp;sysjobid._%sysfunc(datetime(),b8601dt))).log ;&lt;/P&gt;
&lt;P&gt;%let LogOutFile = &amp;amp;Test_path./&amp;amp;Log_file_name.;&lt;BR /&gt;filename stplog "&amp;amp;LogOutFile.";&lt;BR /&gt;proc printto log=stplog;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it creates log files , with same sysjobid with different times&lt;/P&gt;
&lt;P&gt;Test_STP_8628_20210922T173146.log&lt;/P&gt;
&lt;P&gt;Test_STP_8628_20210922T173144.log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In practice , where my program runs&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;distributed across servers and runs parallel&amp;nbsp; in same time , Can&amp;nbsp; &amp;amp;sysjobid will differ and create different log files ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Sep 2021 14:59:26 GMT</pubDate>
    <dc:creator>learn_SAS_23</dc:creator>
    <dc:date>2021-09-22T14:59:26Z</dc:date>
    <item>
      <title>How to create different log files per process id or session</title>
      <link>https://communities.sas.com/t5/Developers/How-to-create-different-log-files-per-process-id-or-session/m-p/769189#M6063</link>
      <description>&lt;P&gt;How to create a log file per session&amp;nbsp;with below command with&amp;nbsp;&lt;SPAN&gt;&amp;amp;sysjobid&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let Log_file_name =%sysfunc(compress(%scan(&amp;amp;_program,-1,/)_&amp;amp;sysjobid._%sysfunc(datetime(),b8601dt))).log ;&lt;/P&gt;
&lt;P&gt;%let LogOutFile = &amp;amp;Test_path./&amp;amp;Log_file_name.;&lt;BR /&gt;filename stplog "&amp;amp;LogOutFile.";&lt;BR /&gt;proc printto log=stplog;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it creates log files , with same sysjobid with different times&lt;/P&gt;
&lt;P&gt;Test_STP_8628_20210922T173146.log&lt;/P&gt;
&lt;P&gt;Test_STP_8628_20210922T173144.log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In practice , where my program runs&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;distributed across servers and runs parallel&amp;nbsp; in same time , Can&amp;nbsp; &amp;amp;sysjobid will differ and create different log files ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 14:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-create-different-log-files-per-process-id-or-session/m-p/769189#M6063</guid>
      <dc:creator>learn_SAS_23</dc:creator>
      <dc:date>2021-09-22T14:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create different log files per process id or session</title>
      <link>https://communities.sas.com/t5/Developers/How-to-create-different-log-files-per-process-id-or-session/m-p/769218#M6064</link>
      <description>&lt;P&gt;The `sysjobid` is the PID and it CAN be the same across multiple sessions.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Your question is confusing as you ARE creating different log files per process / session due to the use of a timestamp.&amp;nbsp; To ensure uniqueness though, you might want to use a random number as well, as shown here:&amp;nbsp;&amp;nbsp;&lt;A href="https://core.sasjs.io/mf__uid_8sas_source.html" target="_blank"&gt;https://core.sasjs.io/mf__uid_8sas_source.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;For even better uniqueness you can use the `uuidgen()` function as shown in this macro:&amp;nbsp;&amp;nbsp;&lt;A href="https://core.sasjs.io/mf__getuniquename_8sas.html" target="_blank"&gt;https://core.sasjs.io/mf__getuniquename_8sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 15:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-create-different-log-files-per-process-id-or-session/m-p/769218#M6064</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-09-22T15:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create different log files per process id or session</title>
      <link>https://communities.sas.com/t5/Developers/How-to-create-different-log-files-per-process-id-or-session/m-p/769598#M6065</link>
      <description>&lt;P&gt;Thanks ,We like to create log file per session (i mean when multiple time client programs calls STP , it should create separate STP log file ) , As the log file available from webserver logs are having less details (we can't able to debug what's wrong with STP) .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;we can create log file with random number from below links&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;amp;today._&amp;amp;now._&amp;amp;sysjobid._%sysevalf(%sysfunc(ranuni(0))*999,CEIL)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 17:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-create-different-log-files-per-process-id-or-session/m-p/769598#M6065</guid>
      <dc:creator>learn_SAS_23</dc:creator>
      <dc:date>2021-09-22T17:22:50Z</dc:date>
    </item>
  </channel>
</rss>

