Log and trace files Rotation in Work Directory
Your application ABAP server has a problem and needs to be restarted ASAP. You restart the application but problem remains. You dig some more and find the source of the problem but need to restart the app again. After the second restart everything is ok and now it is time for the post-investigation.
You want to check the logs and traces in the WORK directory but there are no logs from the period prior to the first restart.
The reason is that the default behavior of the SAP application server is to rotate the logs and traces once after each restart without any retention of the current .old files.
I’ve looked all over for any profile parameter which controls the rotation behavior but couldn’t find any (if anyone knows about one – please keep me posted so i could stop using the following solution….)
So here is our workaround for keeping logs and traces as much as we need regardless the number of restarts (Credit goes to my mentor Igal Serban):
We wrote a python script that creates a folder with the current date & time and copies all of the logs & traces from the WORK directory to that directory.
[In addition our script also contains the following rules: If the file is over 100mb it is not copied but renamed with “TOOBIG” as an extension (so it won’t prolong the startup), folders that are older than 2 weeks are deleted – unless there are less than three folders (it always keeps the last three).]
We’ve converted the py script to exe and added it as “Start_Program_00” in the application server’s start profile – so it will be the first thing that runs before the system starts.
We can restart the system as much as we need – and still have the logs and traces kept in their own folder.
If someone knows a better \ simpler way to keep the work directory content regardless to the number of restarts – i’d like to know.
If anyone wants the script i’d be happy to share it.