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.
Los códigos y ejemplos proporcionados en WeAreCAS.eu son con fines educativos. Es imperativo no copiarlos y pegarlos ciegamente en sus entornos de producción. El mejor enfoque es comprender la lógica antes de aplicarla. Recomendamos encarecidamente probar estos scripts en un entorno de prueba (Sandbox/Dev). WeAreCAS no acepta ninguna responsabilidad por cualquier impacto o pérdida de datos en sus sistemas.
SAS y todos los demás nombres de productos o servicios de SAS Institute Inc. son marcas registradas o marcas comerciales de SAS Institute Inc. en los EE. UU. y otros países. ® indica registro en los EE. UU. WeAreCAS es un sitio comunitario independiente y no está afiliado a SAS Institute Inc.
Este sitio utiliza cookies técnicas y analíticas para mejorar su experiencia.
Saber más.