ftos.logging.setProperty
IMPORTANT!
Starting with v24.3.0, this is renamed from server.logging.setProperty to ftos.logging.setProperty.
Starting with v24.3.0, this is renamed from server.logging.setProperty to ftos.logging.setProperty.
Sets a custom property to be included in log messages.
This is a method suitable for all business service components modules.
Syntax
Copy
function ftos.logging.setProperty(propertyKey: string, propertyValue: string): void
| Parameter | Description |
|---|---|
propertyKey
|
Custom key to be included in the log message properties. |
propertyValue
|
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 ftos.logging.getProperty to store the key's value in the x variable.
- We ftos.logging.log a message that emphasizes the value of the fooKey custom logging property.
Copy
ftos.logging.setProperty('fooKey', 'fooValue');
var x = ftos.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]---------------------------------------