Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

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. 


A POC with VES Collector 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:

  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: https://github.com/onap/ci-management/tree/master/jjb/dcaegen2
  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: https://wiki.web.att.com/pages/viewpage.action?spaceKey=DPD&title=Pushing+Code+to+ONAP+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: 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

Medium Level of Effort:

  • Rest-conf


  • No labels