Logging in the REST API server

This topic discusses logging options in the HCL OneDB™ REST API server.

The default logging mechanism for the REST API is Log4j. Log4j uses a configuration file to customize the level, style and target location for log messages. You can customize the logging output to fit your needs or to provide diagnostics for a technical support representative.

Below is a generic example log4j2.xml file which allows you control logging for the REST API using the Java system properties specified in the table.

-Dlog4j2.configurationFile Specify the location of the XML configuration file
-Dapp.logtarget Specify 'console' or 'file'
-Dapp.logfile If logtarget is 'file' give a file path here
-Dapp.loglevel Specify the log level of the application
-Djdbc.loglevel Specifiy the log level of the underlying JDBC driver
<?xml version="1.0" encoding="UTF-8"?>
<!--
	Generic Log4j2 configuration file that gives custom
	levels for JDBC and the application itself
-->
<Configuration monitorInterval="30" status="WARN">
  <Properties>
    <Property name="lgtarget">$${sys:app.logtarget:-console}</Property>  
    <Property name="lgfile">$${sys:app.logfile:-app.log}</Property>
    <Property name="app">$${sys:app.loglevel:-info}</Property>
    <Property name="jdbc">$${sys:jdbc.loglevel:-error}</Property>
    <Property name="pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5level | %t | %c{1} | %method | %marker | %msg%n</Property>
  </Properties>
  <Appenders>
    <Routing name="Router">
      <Routes pattern="${lgtarget}">
        <Route ref="Console" key="console" />
        <Route ref="File" key="file" />
      </Routes>
    </Routing>
    <Console name="Console">
      <PatternLayout pattern="${pattern}" />
    </Console>
    <File name="File" fileName="${lgfile}">
      <PatternLayout pattern="${pattern}" />
    </File>
  </Appenders>
  <Loggers>
    <!-- JDBC Driver packages -->
    <Logger name="com.informix" level="${jdbc}" />
    <Logger name="com.onedb.jdbc" level="${jdbc}" />
    <Logger name="com.onedb.jdbcx" level="${jdbc}" />
    <!-- Disable arcs/hikari logging except for errors -->
    <Logger name="com.informix.arcs" level="error" />
    <Logger name="com.zaxxer.hikari" level="warn" />

    <Root level="${app}">
      <AppenderRef ref="Router"/>
    </Root>
  </Loggers>
</Configuration>