server.logging.setProperty
(Innovation Studio 22.1 and later)
Sets a custom property to be included in log messages.
Syntax
Copy
function server.logging.setProperty(key: string, value: string): void
| Parameter | Description |
|---|---|
key
|
Custom key to be included in the log message properties. |
value
|
Value of the custom log property key. |
Examples
In this example:
- We use define a custom log property called fooKey and assign it the fooValue value.
- We use the server.logging.getProperty to store the key's value in the x variable.
- We log a message that emphasizes the value of the fooKey custom logging property.
Copy
server.logging.setProperty('fooKey', 'fooValue');
var x = server.logging.getProperty('fooKey');
log('Check out the fooKey custom property below which is set to ' + x);
The resulting log message will be similar to the one below:
Copy
-[START]---------------------------------------
Timestamp: 17/12/2021 02:10:56 PM
Message: Check out the fooKey custom property below which is set to fooValue
Severity: Information
Exception:
Properties: { CorrelationId: "23cdb1f5-0529-4377-b200-399efb8bc32f", PortalProfile: null, MachineName: "FTOSBUCLP385", Language: "en-GB", Source: "Platform", fookey: "fooValue", automationscript: "sample-script-log-api" }
-[END]---------------------------------------