Reference for the logging standardization effort: Jakarta Best Practice Proposal for Standardized Logging Fields - v2
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}" />
</JsonLayout>
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 – https://logging.apache.org/log4j/2.x/runtime-dependencies.html
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 can be found here: https://gerrit.onap.org/r/c/dcaegen2/collectors/ves/+/132585
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: https://logging.apache.org/log4j/2.x/manual/lookups.html https://www.tutorialspoint.com/log4j/log4j_patternlayout.htm
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:
- 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: https://github.com/onap/ci-management/tree/master/jjb/dcaegen2
- 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: https://wiki.web.att.com/pages/viewpage.action?spaceKey=DPD&title=Pushing+Code+to+ONAP+Gerrit
Jira Ticket for DCAE logging Specs: - DCAEGEN2-3257Getting issue details... STATUS
CPS Logback POC: CPS-986 : Asynchronous Communication Logging
CPS Jira: - CPS-986Getting issue details... STATUS
CPS Gerrit: https://gerrit.onap.org/r/c/cps/+/128801/13/cps-service/src/main/resources/logback-spring.xml
List of Application Status with log4j:
Done:
- Ves-collector (https://gerrit.onap.org/r/c/dcaegen2/collectors/ves/+/132585)
Medium level of effort:
- Rest-conf