The FNZ Studio/Appway Platform uses Apache Log4j as a logging framework. FNZ Studio 2023 comes with a new major version of Log4j (v2). This new major version uses a new syntax for its configuration. While FNZ Studio comes with a default configuration for Log4j, clients may decide to replace or patch the default configuration for their installation. If such custom configuration is used, manual migration steps are required to convert the configuration to the new syntax.
Two different files are used to replace or patch the default Log4j configuration:
$DATA_HOME/conf/log4j.properties (replace default configuration)$DATA_HOME/conf/log4j-additional.properties (patch default configuration)
If your installation of Appway/FNZ Studio contains these files, you can stop reading here, as there is no need for migration. Otherwise, read the following sections for further details.
Since the new major version of Log4j (v2) uses a different configuration syntax, we use two new configuration files:
$DATA_HOME/conf/log4j2.properties (replaces default configuration)$DATA_HOME/conf/log4j2-additional.properties (patches default configuration)
Note the extra "2" in the file name. This is a reference to the new Log4j major version 2.x.
Note that you do not need to migrate the Log4j configuration BEFORE you upgrade an existing installation to FNZ Studio 2023.x.x. You can migrate the custom Log4j configuration afterwards, as a post-upgrade activity as reported in System Upgrade: FNZ Studio 2022.2 to 2023 LTS . However, consider that FNZ Studio 2023 will not find the new configuration files and, therefore, will start with its built-in default configuration for Log4j and will completely ignore the old Log4j configuration files until you migrate the Log4j configuration.
The first step is to copy the existing Log4j configuration files, giving them the new names:
log4j.properties should be renamed log4j2.properties
log4j-additional.properties should be renamed log4j2-additional.properties
Important: If you run an Appway/FNZ Studio cluster, you need to execute these migration steps on every cluster node.
Next, you will need to adapt the content of the new Log4j configuration files to the new configuration syntax.
Log4j configuration files can contain properties for different components:
- Define loggers
- Set logger levels (DEBUG, INFO, ...)
- Define appenders (usually log files)
- Attach appenders to loggers
- etc.
For some of these properties, syntax changes are less dramatic, therefore we have implemented a partial converter. This means that you do not need to rewrite everything in the Log4j configuration, but you can continue to use some of the old properties. Lines starting with one of the following strings do NOT need to be changed:
log4j.rootLoggerlog4j.logger.log4j.additivity.
These are the most common properties. Possibly, your Log4j configuration file contains only such properties, in which case you only need to rename your Log4j configuration file in order to complete the migration.
Note: Appway/FNZ Studio does not physically change the contents of your Log4j configuration files. Instead, conversion is applied in memory when reading the contents of these files.
If your Log4j configuration file contains properties starting with any of the following strings, then manual work is required:
log4j.thresholdlog4j.appender.
If you have set a global threshold for log levels through the log4j.threshold property, you need to rewrite the configuration as in the following example.
Old configuration:
log4j.threshold = WARN
New configuration:
filter.root.type = ThresholdFilter
filter.root.level = WARN
You can use a value other than "root", as long as it is unique among all the filter definitions.
The syntax used to define appenders has changed remarkably. For this reason, we only provide here two examples for appenders with different rollover strategies, using the new syntax. Both examples define an appender with name "demo" where log messages are written to a log file "demo.log" inside FNZ Studio's directory for log files in the data home.
The common part:
appender.demo.type = RollingFile
appender.demo.name = demo
appender.demo.fileName = ${nm.data.home}/logs/demo.log
appender.demo.layout.type = PatternLayout
appender.demo.layout.pattern = %d %-5p [%t] %c - %m%n%throwable
Example 1: Use a time-based rollover strategy, creating one log file every day:
appender.demo.policy.type = TimeBasedTriggeringPolicy
appender.demo.strategy.type = DefaultRolloverStrategy
appender.demo.strategy.fileIndex = nomax
appender.demo.filePattern = ${nm.data.home}/logs/demo.log.%d{yyyy-MM-dd}
Example 2: Use a size-based rollover strategy with a maximum file size of 4 MB, keeping at most 4 old log files:
appender.demo.policy.type = SizeBasedTriggeringPolicy
appender.demo.policy.size = 4MB
appender.demo.strategy.type = DefaultRolloverStrategy
appender.demo.strategy.fileIndex = min
appender.demo.strategy.max = 4
appender.demo.filePattern = ${nm.data.home}/logs/demo.log.%i
You need to look at your existing appender definitions starting with log4j.appender. and manually rewrite them to follow the above syntax.
If you have troubles migrating your Log4j configuration, please open a Support Ticket and attach your old Log4j configuration files.