Skip to main content Skip to complementary content

Configuring a JMS appender

You may want to send logs to an ActiveMQ backend system.

Talend Cloud supports the ActiveMQ TCP protocol.

Procedure

  1. Open the <RemoteEngineInstallationDirectory>/etc/org.ops4j.pax.logging.cfg file and add the following lines:

    Example

    log4j2.appender.jms.type = Jms
    log4j2.appender.jms.name = JmsAppender
    log4j2.appender.jms.destinationBindingName= dynamicQueues/myQueueName1
    log4j2.appender.jms.factoryName=org.apache.activemq.jndi.ActiveMQInitialContextFactory
    log4j2.appender.jms.factoryBindingName=ConnectionFactory
    log4j2.appender.jms.providerURL=tcp://localhost:616162
    log4j2.appender.jms.userName=admin 
    log4j2.appender.jms.password=admin3
    log4j2.appender.jms.layout.type = JsonTemplateLayout
    log4j2.appender.jms.layout.eventTemplateUri=${karaf.base.uri}/etc/jsonLogMinTemplate.json
    log4j2.appender.jms.layout.stackTraceElementTemplateUri=${karaf.base.uri}/etc/StackTraceElementLayout.json
    
    log4j2.rootLogger.appenderRef.JmsAppender.ref = JmsAppender
  2. Save the file.
  3. Add the Mapped Diagnostic Context (MDC) information to the JSON template file so that the output logs, where applicable, contain the MDC information. This MDC information includes the run ID of a Talend Management Console task.
    1. In <RemoteEngineInstallationDirectory>/etc, create a file and name it as jsonLogMinTemplateCustom.json.
    2. Add the following lines to this new file to create a MDC resolver:

      Example

      {
         "logMessage": {
            "$resolver": "message", 
            "stringified": true
         },
         "my_mdc": { 
            "$resolver": "mdc" 
         },
         "logTimestamp": {
            "$resolver": "timestamp", 
            "epoch": {
               "unit": "millis", 
               "rounded": true
             }
         },
          "severity": {
             "$resolver": "level",
             "field": "name"
         },
          "ticLogLevel": {
             "$resolver": "source", 
             "field": "ticLogLevel"
         }
      }

      The example defines a JSON object to specify the fields to include in the MDC output. The object uses key-value pairs, where the keys represent the output fields and the values specify the resolvers to populate those fields

      The "my_mdc": { "$resolver": "mdc" } line creates a field called my_mdc in the output. The mdc resolver populates this field with all MDC fields, which provide additional diagnostic information associated with the logs. A my_mdc field can look like this:
      { 
        "accountID":"31e47fe5-abcd-4a80-a8b2-590123456789",
        "bundle.id":"289",
        "bundle.name":"org.talend.ipaas.engine.deployment-agent",
        "bundle.version":"2.13.7",
        "executionDestination":"REMOTE_ENGINE",
        "flowExecutionId":"ed31c1a8-abcd-4121-98bd-cd0123456789",
        "flowID":"61fbfc899e86410123456789",
        "flowVersion":"45.28",
        "remoteEngineId":"c62cd9a1-abcd-4580-8af1-220123456789",
        "userId":"user.talend.com",
        "workspaceId":"5ef6605b2632fd1234567890"
      }
      To retrieve specific MDC fields such as flowID (representing a task ID) and flowExecutionId (representing a task run ID), replace the "my_mdc": { "$resolver": "mdc" } line with:
      "taskId": {"$resolver": "mdc", "key": "flowID"},
      "executionId": {"$resolver": "mdc", "key": "flowExecutionId"},
      The field names taskId and executionId are just examples. You can use any meaningful names to receive the MDC fields you want to include in the output.
  4. Configure your JMS system to use this new jsonLogMinTemplateCustom.json template instead of the default template file jsonLogMinTemplate.json.
1 This is an example. The destinationBindingName could be dynamicQueues/myQueueName or dynamicTopics/myTopicName.
2 This is an example. You need to define your JMS host and its port.
3 This admin is only an example for userName and password.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!