Logging in the REST API server
This topic discusses logging options in the HCL OneDB™ REST API server.
By default, the REST API server will log informational messages, errors,
and warnings to a log file named
onedb-rest.log
.
The REST API server comes bundled with the Logback library which is used for logging. Logback is pre-configured to log to a file at the INFO level.
You can customize the logging level (INFO, ERROR, WARN, DEBUG, TRACE) and
the logging location (console, file, etc.) by creating your own
logback.xml
file. This logback.xml
file can
either be in the current directory or in the classpath when you start the REST API server. For more information on
how to customize Logback, see http://logback.qos.ch/.
Below you will find an example logback.xml
file. This
file shows a sample logback configuration that logs to a file. There are commented
out sections showing examples of logging to the console or using file-based logging
with rolling window policy.
<configuration scan="true" scanPeriod="5 seconds">
<!-- A simple console appender -->
<!-- Uncomment this section to logging to the console -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
-->
<!-- This appender section produces the typical onedb-rest.log file -->
<!-- See https://logback.qos.ch/manual/layouts.html#ClassicPatternLayout for details -->
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<append>true</append>
<file>onedb-rest.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<!-- Uncomment this section if you want to use a rolling log window -->
<!-- See https://logback.qos.ch/manual/appenders.html#RollingFileAppender for details -->
<!--
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>onedb-rest.rolling.log</file>
<append>true</append>
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>onedb-rest.rolling.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
-->
<!-- The base logging level is set here -->
<!-- You can choose from (TRACE, DEBUG, INFO, WARN, ERROR) -->
<root level="INFO">
<!-- <appender-ref ref="CONSOLE" /> -->
<appender-ref ref="FILE" />
</root>
<!-- You can configure custom logging levels (TRACE, DEBUG, INFO, WARN,
ERROR) for any java package name -->
<!--<logger name="com.onedb.rest.api" level="DEBUG" />-->
<!--<logger name="com.onedb.rest.sql" level="DEBUG" />-->
<!--<logger name="com.informix.jdbc" level="INFO" />-->
<!--<logger name="com.zaxxer.hikari" level="INFO" />-->
</configuration>