Log file in Application Engine
A typical example of Log file creation in application engine using peoplecode is given below.
local File &Log_file;
&Log_file = GetFile(“c:\temp\logfilename.txt”, “W”, %FilePath_Absolute);
&Log_file.WriteLine(“Begin Process : ” | %Datetime);
&Log_file.close()
But if you have to use the same log file across the sections within an application engine, then
Declare the file as global in one of the initial step as given below.
Global File &Log_file;
&Log_file = GetFile(“c:\temp\logfilename.txt”, “W”, %FilePath_Absolute);
&Log_file.WriteLine(“Begin Process : ” | %Datetime);
Then in any following section’s peoplecode step, declare the global variable and start writing to the file.
Global File &Log_file;
&Log_file.WriteLine(“Write anything here”);
Don’t forget to close the log file at the end of application engine.
Global File &Log_file;
&Log_file.close()
This is good for simple stats like start date time etc.
How would you go about when the requirement is to log stats at the end of the process such as, no of rows updated, no of rows inserted etc?
keep a global variable counter, whenever you are updating or inserting the rows add one to the counter.At the end of the process write this counter to the log file.