The web browser trick: A little-known but very effective solution is to open your .log file directly with a browser (Internet Explorer, Chrome, Edge, etc.). The browser does not lock the file and displays the text correctly (especially if the extension is .log, the formatting remains readable).
Note : The "Dashboard" Solution: PROC PRINTTO and HTML
To go beyond simple text reading, you can redirect your logs to an HTML format. This allows you to create real monitoring dashboards (with colored statuses: green for finished, yellow for in progress, etc.).
The idea is to use the PROC PRINTTO procedure to route the log to an HTML file. Here is an example of a macro proposed by the community:
%MACRO PRINTTO(_logPath=, _jobID=, _jobName=);
%LOCAL dt;
%LET dt = %sysFunC(dateTime(), DATETIME16.);
/* Initialisation du fichier HTML */
FILENAME L_PATH "&_logPath";
DATA _null_;
file L_PATH;
put "<PRE>"; /* Balise pour conserver le formatage */
RUN;
FILENAME L_PATH CLEAR;
/* Redirection de la log */
PROC PRINTTO LOG = "&_logPath";
RUN;
%PUT NOTE: Job &_jobID - &_jobName a demarre a &dt;
%MEND;
1
%MACRO PRINTTO(_logPath=, _jobID=, _jobName=);
2
%LOCAL dt;
3
%LET dt = %sysFunC(dateTime(), DATETIME16.);
4
5
/* Initialisation du fichier HTML */
6
FILENAME L_PATH "&_logPath";
7
DATA _null_;
8
file L_PATH;
9
put "<PRE>"; /* Balise pour conserver le formatage */
10
RUN;
11
FILENAME L_PATH CLEAR;
12
13
/* Redirection de la log */
14
PROC PRINTTO LOG = "&_logPath";
15
RUN;
16
17
%PUT NOTE: Job &_jobID - &_jobName a demarre a &dt;
18
%MEND;
By opening this HTML file in a browser and using automatic refresh, you can comfortably track the progress of your jobs.
The Empty File Problem (Buffering)
Even if you manage to open the file, its size often remains stuck at 0 KB or does not update for long periods, even if the program is running.
Limitations: Although very useful, this option does not always guarantee an instant, second-by-second update (it also depends on the disk load and the OS), but it significantly reduces the delay in the appearance of logs.
You can also combine this with the -logparm option:
-logparm "write=immediate rollover=session"
4. Third-party Tools: Bringing Unix to Windows
If you miss tail -f too much, the radical solution is to install utilities that bring Unix commands to Windows. Tools like GnuWin32, UnxUtils, or Cygwin allow you to use tail on Windows to monitor your log files exactly as you would on a Linux server.
Les codes et exemples fournis sur WeAreCAS.eu sont à but pédagogique. Il est impératif de ne pas les copier-coller aveuglément sur vos environnements de production. La meilleure approche consiste à comprendre la logique avant de l'appliquer. Nous vous recommandons vivement de tester ces scripts dans un environnement de test (Sandbox/Dev). WeAreCAS décline toute responsabilité quant aux éventuels impacts ou pertes de données sur vos systèmes.
SAS et tous les autres noms de produits ou de services de SAS Institute Inc. sont des marques déposées ou des marques de commerce de SAS Institute Inc. aux États-Unis et dans d'autres pays. ® indique un enregistrement aux États-Unis. WeAreCAS est un site communautaire indépendant et n'est pas affilié à SAS Institute Inc.
Ce site utilise des cookies techniques et analytiques pour améliorer votre expérience.
En savoir plus.