PTC ALD in Arbortext Styler > Components of Documents and Templates > Logging > Creating a Log Entry
  
Creating a Log Entry
As mentioned previously, logs 5 to 8 are available for template developers to use as their own logs. This example code accesses log 5:
var log = application.logs[5];
This example code opens the same log once accessed:
var log = application.logs[5];
log.open(1, "D:/myLogFile.txt");
The code also creates the log file D:/myLogFile.txt. Opening the log creates a new log, so any existing content is automatically cleared. To avoid the clearance, use code as shown in this example:
var log = application.logs[5];
if (log.isOpen == false) log.open(1, "D:/myLogFile.txt");
This opens the log if it is not already open. Using the fLog.close() command closes the log. Do not close the log until the job is finished, unless you only want it to contain a single message.
To write messages to the log once it is opened, use code as shown in this example:
var log = application.logs[5];
if (log.isOpen == false) log.open(1, "D:/myLogFile.txt");
log.write("Hello world");
log.write("\n");
This example writes the text Hello world into the log, followed by a hard return.
You can open the log as an PTC Arbortext Layout Developer tag, as shown in this example:
var log = application.logs[5];
if (log.isOpen == false) log.open(2, "myLogTag");
where myLogTag is the name of the tag to be used as the log.
You can configure your log message to appear as a pop-up alert message, as shown in this example:
var log = application.logs[5];
if (log.isOpen == false) log.open(4);
You can output to the Event Log, a useful debugging tool in Arbortext Styler, as shown in this example:
var log = application.logs[1];
log.write("my message here!");