Reference for the logging standardization effort: Jakarta Best Practice Proposal for Standardized Logging Fields - v2

This requirement outlines that we can use JSON, CSV, or any other delimited format as long as the field names are present.

JSON Output

For DCAE components using log4j as the logger, update the log4j.xml file CONSOLE appender layout accordingly:

<JsonLayout eventEOL="true" compact="true" stacktraceAsString="true" properties="true" propertiesAsList="true">
        <KeyValuePair key="logTimeStamp" value="$${date:yyyy-MM-dd HH:mm:ss:-null}" />
        <KeyValuePair key="logTypeName" value="$${event:Logger:-null}" />
        <KeyValuePair key="logLevel" value="$${event:Level:-null}" />
        <KeyValuePair key="traceId" value="${:-null}" />
        <KeyValuePair key="statusCode" value="${:-null}" />
        <KeyValuePair key="principalId" value="${:-vescollector}" />
        <KeyValuePair key="serviceName" value="${k8s:containerName:-vescollector}" />
        <KeyValuePair key="exception" value="$${event:Exception:-None}" />
        <KeyValuePair key="PID" value="$${sys:pid:-null}" />

The final block should look like:

The runtime dependencies needed in pom.xml should already be there if the project has log4j, but they can be found here –

Once the XML files are updated, you should be able to rebuild the application and see the logs reflected in STDOUT. 

The VES Collector changes to accomplish this goal can be found here:

String Output

Log4j has the capability of providing these fields in the normal output of just a string too. Here is some documentation on the tags that are available out of the box with log4j:

General Notes

These notes are going to be here for extra help navigating the building and testing process to see if your logging changes are working:

  1. You may have to build the project from a subdirectory rather than the base project directory. This CI Management repo will help clarify where each of the projects are building from to better identify the subdirectory you should build from:
  2. You will need the onap-settings.xml file to build each project. You can download it here: onap-settings.xml

Misc Resources:

Git Review: Setting Up Your Development Environment#git-review(optional)

ONAP Dev Env Overview: Development Procedures and Policies

Pushing to Gerrit:

Jira Ticket for DCAE logging Specs: DCAEGEN2-3257 - Getting issue details... STATUS

CPS Logback POC: CPS-986 : Asynchronous Communication Logging

CPS Jira: CPS-986 - Getting issue details... STATUS

CPS Gerrit:

List of Application Status with log4j:


Medium level of effort*:

  • Rest-conf

*- will take longer (and more troubleshooting) than basic changes to the XML files to complete the ask.

  • No labels