In this recipe, we will look into how logging works in scripting. You will learn how to create log entries and where they are stored.
We just need a working Orchestrator, and you will need the rights to create new workflows and run them. We will work with the Orchestrator Client.
Additionally, we need administrative (root) access to the Orchestrator's operating system.
We will split this recipe into two sections, Creating logs and Checking the log files.
We will now create log entries during a workflow:
Name |
Type |
Section |
Binds with |
|
String |
IN |
Transports error text |
|
String |
IN |
Transports object text |
Logs are an important tool for programmers and for system administrators. Log files help programmers understand where a program went wrong or show them the values of variables during runtime. For system administrators, log files help them keep track of who ran what workflow, and when.
In logs generated by the execution of a workflow, you can copy the content (the copy icon), insert a ***
line (the pencil icon), or delete the whole log (the red X icon) and filter by criticality, and even switch between pages.
The main difference between server and system logs is that server logs are stored in the Orchestrator database and system logs are stored in the system's log files. This is especially important if you work with Orchestrator clusters; see the recipe Building an Orchestrator cluster recipe in Chapter 3, Distributed Design.
The server log files get rolled as specified in the recipe Orchestrator log files in Chapter 2, Optimizing Orchestrator Configuration. Server logs are stored with the workflow execution until purged depending on user settings (see the recipe User preferences in Chapter 7, Interacting with Orchestrator). Server logs are persistent as they are stored in log files on the Orchestrator server.
A log event can have four categories:
Syslog value |
Debug |
Info |
Warn |
Error |
Workflow element |
- |
Log |
Warning |
Error |
Logs |
[D] |
[I] |
[W] |
[E] |
JavaScript |
|
|
|
|
|
|
|
|
Each of the four categories can be chosen at will. Any information that would be critical to troubleshoot a workflow several hours/days after it's run should be logged using the server.
In JavaScript, using logs is quite a good way to fix bugs. A typical thing to do is to write out variables that exist only inside a script element, for example, System.log("Mark")
, System.log("Log: "+variable)
.
There are multiple ways to check the physical log files. The most common one is to check the log files on the Orchestrator OS. The one we are interested in is: /var/log/vco/app-server/scripting.log
.
This directory also contains other log files that are discussed in the recipe Orchestrator log files in Chapter 2, Optimizing Orchestrator Configuration.
This directory contains all information about running scripts. When we look at it, we should see the following entry for our example workflow:
2016-04-22 23:38:04.140+0200 INFO {[email protected]:40285c8c543d802d01543fe885a40127} [SCRIPTING_LOG] [05.01 Working with Logs (4/22/16 23:38:03)] LogText - LogObject
There is quite a lot of information, for example, what workflow (05.01 Scripting with Logs
) was executed and also the Orchestrator user ([email protected]
) who executed it.
Alternatively, instead of logging into the appliance, you can use the Control Center to access logs in two ways:
scripting.log
from the Control Center file browser in the /app-server-logs
folderFor the last two methods, please see the recipe Control Center titbits in Chapter 2, Optimizing Orchestrator Configuration.
The example workflow, 05.01 Scripting with Logs
.
The recipe, Redirecting Orchestrator logs to an external server in Chapter 2, Optimizing Orchestrator Configuration.
The recipe, Orchestrator log files in Chapter 2, Optimizing Orchestrator Configuration.
There is a nice example in the recipe, Building an Orchestrator cluster in Chapter 3, Distributed Design to show the difference between server and system logs.