"log4j2.xml" RollingFileAppender settings to customize sql.log in TIBCO Spotfire server

"log4j2.xml" RollingFileAppender settings to customize sql.log in TIBCO Spotfire server

book

Article ID: KB0075041

calendar_today

Updated On:

Products Versions
Spotfire Server 7.9 and higher

Description

Starting Spotfire 7.9 the logging framework was upgraded from Log4j to Log4j2. There are ways to customize the "log4j2" logging as per your requirement.

The below article describes about customizing "sql.log" to create a new log everyday. By default the logging policy is size based.

Environment

All supported Operating systems.

Resolution

Default setting:
--------------------
      <RollingFile name="sqllog" fileName="${basedir}/server.log"
                 filePattern="${basedir}/sql.log.%i">
      <Policies>
                <SizeBasedTriggeringPolicy size="${sqlLogSizePolicy}"/>
      </Policies>
      <DefaultRolloverStrategy max="${serverLogDefaultRollover}" fileIndex="min"/>
                <PatternLayout pattern="${standardLogPattern}"/>
    </RollingFile>
--------------------

Change the "filePattern" and the policies as below and save the file.
----------------------
       <RollingFile name="serverlog" fileName="${basedir}/server.log"
                 filePattern="${basedir}/server.%d{yyyy-MM-dd}.log">
      <Policies>
               <TimeBasedTriggeringPolicy interval="1" modulate="true" />
      </Policies>
      <DefaultRolloverStrategy max="${serverLogDefaultRollover}" fileIndex="min"/>
              <PatternLayout pattern="${standardLogPattern}"/>
    </RollingFile>
----------------------

- Restart the Spotfire server service for the changes to take effect.


NOTE:
1) Backup the log4j2.xml before editing it.
2) The settings need to be re-done in case of a Spotfire Server upgrade

Issue/Introduction

"log4j2.xml" RollingFileAppender settings to customize sql.log in TIBCO Spotfire server

Additional Information

https://logging.apache.org/log4j/2.x/manual/configuration.html
https://howtodoinjava.com/log4j2/log4j2-rollingfileappender-example/