Before you begin, review the Supported Log Frameworks.
The following metadata is added to logs:
- appd_node_id
- appd_request_guid
- appd_bt_id
If the metadata keys are added to defaultMeta
, the agent updates the keys with the correct value at runtime. However, if no keys are present, the key values are determined from the appdynamics_log_metadata_fields
environment variable. In this case, the metadata is embedded into the message field of the logs.
For structured logs, you must define the metadata fields in the logger. Here is an example of metadata fields defined in the logger.
User Defined Metadata Fields in Structured Log
const logger = winston.createLogger({
level: 'debug',
format: winston.format.json(),
/* user adds the keys they want to see in the log output to the metadata */
defaultMeta: {appd_node_id: '', appd_request_guid: '', appd_bt_id: ''},
transports: [
new winston.transports.File({ filename: 'message.log'}),
],
});
XML
For unstructured logs, you do not define the metadata fields; the log output fields are determined from the appdynamics_log_metadata_fields
variable. Here is an example of an unstructured log configuration in the logger.
Undefined Metadata Fields in Unstructured Log
const logger = winston.createLogger({
level: 'debug',
format: winston.format.simple(),
defaultMeta: {appd_node_id: '', appd_request_guid: '', appd_bt_id: ''},
transports: [
new winston.transports.File({ filename: 'message.log'}),
],
});
XML