Logging in JSON format

By default, Adeptia Connect stores and displays the log messages in standard format. However, it also gives you the flexibility to log and display the messages in popular format like JSON. To set your preference for output in JSON format, you need to follow the steps below:

  1. Go to …<ConnectServerInstallFolder>\AdeptiaServer\ServerKernel\etc location.
  2. Open log4J-2.xml file.
  3. Comment out the code as shown below:

     <!--  <Console name="console" target="SYSTEM_OUT">
                <PatternLayout pattern="${sys:log4j.appender.console.layout.ConversionPattern}"/>
           </Console>-->
  4. Insert the code given below inside the <Appenders>...</Appenders> tags in the file:

    <RollingFile name="console" fileName="${sys:abpm.kernelout.file.location}/${sys:log4j.appender.file.File}"
               filePattern ="${sys:abpm.kernelout.file.location}/${custom:log4j.appender.file.File}-%d{yyyy-MM-dd}-%i.log">
                <JSONLayout compact="true" eventEol="true"/>
                <Policies>
                <SizeBasedTriggeringPolicy size="${sys:log4j.appender.retry.file.MaxFileSize}" />
                </Policies>
                <DefaultRolloverStrategy max="${sys:log4j.appender.retry.file.MaxBackupIndex}"/>
           </RollingFile>
  5. Save the file.

Setting this preference creates two new files 'KernelSystem.log' and 'WebrunnerSystem.log' which contain the logs in JSON format.  These files contain the log messages written by log4j 2.

You can use the JSON layout parameters in log4J-2.xml file based on your requirements. Click here to know more about the parameters.