FNZ Studio uses Apache Log4j 2 as the logging framework. This article describes how Log4j is initialized and configured by FNZ Studio, and how you can modify this configuration.
The configuration property nm.log4j.initialize determines whether FNZ Studio initializes the Log4j framework on start-up. The default value of this property is true.
To disable the Log4j initialization, set this property to false in the server configuration. This can be necessary if some other component of your execution environment already has initialized Log4j, for example your Java application server.
If you set this property to false, FNZ Studio will not create the log files error.log and debug.log automatically.
FNZ Studio has a built-in Log4j configuration file. The file is located on the class path under com/nm/conf/log4j2.properties.
The configuration presented below is just an example, showing the most important settings. To download the correct and full logging configuration for your FNZ Studio release from the Studio, go to System Maintenance > Logging > Settings. Right-click on the desired configuration and select Download.
# report errors to stdout
rootLogger = ERROR, stdlog, clustertmplog, libslog
# default logger for FNZ Studio
# do not pass log messages to loggers above (no additivity)
log4j.logger.com.nm = WARN, stdlog, clustertmplog, errlog, dbglog
log4j.additivity.com.nm = false
# temporary, in-memory cluster log
# this appender will be replaced with the real cluster log during start-up.
appender.clustertmplog.type = ClusterLogInMemoryAppender
appender.clustertmplog.name = clustertmplog
# console appender for stdout
appender.stdlog.type = Console
appender.stdlog.name = stdlog
appender.stdlog.layout.type = PatternLayout
appender.stdlog.layout.pattern = %d %-5p [%t] %c - %m%n%throwable
# default FNZ Studio debug.log
appender.dbglog.type = RollingFile
appender.dbglog.name = dbglog
appender.dbglog.fileName = ${nm.data.home}/logs/debug.log
appender.dbglog.filePattern = ${nm.data.home}/logs/debug.log.%i
appender.dbglog.strategy.type = DefaultRolloverStrategy
appender.dbglog.strategy.max = 4
appender.dbglog.strategy.fileIndex = min
appender.dbglog.policy.type = SizeBasedTriggeringPolicy
appender.dbglog.policy.size = 4MB
appender.dbglog.layout.type = PatternLayout
appender.dbglog.layout.pattern = %d %-5p [%t] %c - %m%n%throwable
# default FNZ Studio error.log
appender.errlog.type = RollingFile
appender.errlog.name = errlog
appender.errlog.fileName = ${nm.data.home}/logs/error.log
appender.errlog.filePattern = ${nm.data.home}/logs/error.log.%d{yyyy-MM-dd}
appender.errlog.strategy.type = DefaultRolloverStrategy
appender.errlog.strategy.fileIndex = nomax
appender.errlog.policy.type = TimeBasedTriggeringPolicy
appender.errlog.filter.threshold.type = ThresholdFilter
appender.errlog.filter.threshold.level = INFO
appender.errlog.layout.type = PatternLayout
appender.errlog.layout.pattern = %d %-5p [%t] %c - %m%n%throwable
[ ... more appenders and loggers ...]
This example configuration contains the following aspects:
- Error messages will be sent to
STDOUT. - Messages from FNZ Studio (package
com.nm) will be sent to STDOUT and the two log files error.log and debug.log. By default, only errors and warnings are reported. - The log file
error.log is saved in the directory <DataHome>/logs and is rotated once a day. The logs from the previous days have a time stamp appended to their name (example: "error.log.2023-01-20"). This file never contains debug messages (level = INFO). - The log file
debug.log is saved in the directory <DataHome>/logs and is rotated whenever its size reaches 4 MB. If this happens, the file is renamed to debug.log.1. If this file already exists, it is first renamed to debug.log.2, and so on. There are 5 debug.log files at maximum, up to debug.log.4.
If you upgrade from Appway or FNZ Studio 2022.2 or older, please note that the names of the Log4j configuration files have changed due to the migration from Log4j 1.2 to Log4j 2. In previous releases, the configuration files have been named
log4j.properties and
log4j-additional.properties. Now with Log4j 2, these configuration files have an extra "2" in the name:
log4j2.properties and
log4j2-additional.properties. See also
System Upgrade: Migrating Log4j Configuration.
On start-up, FNZ Studio will check if there is a file log4j2.properties in the directory <DataHome>/conf. If the file exists, it will be used to initialize Log4j. This basically REPLACES the default configuration. You can use this method if you must do fundamental changes on how Log4j is initialized.
If you only need to add, change, or remove some configuration properties, create a file called log4j2-additional.properties. If this file exists on start-up, FNZ Studio uses its content to OVERRIDE the properties loaded from the default configuration or from the log4j2.properties file above. You can use this method if you would like to make a single logger level persistent:
log4j.logger.com.nm.services.WorkflowEngineServiceImpl = DEBUG
Or you can attach additional log files to FNZ Studio components:
log4j.logger.com.nm.filter.DebugFilter = DEBUG, reqlog
log4j.additivity.com.nm.filter.DebugFilter = false
appender.reqlog.type = RollingFile
appender.reqlog.name = reqlog
appender.reqlog.fileName = ${nm.data.home}/logs/reqlog.log
[...]
Setting a Log4j configuration to value TO_BE_REMOVED causes the removal of this property. As opposed to redefining a property (override), setting the value TO_BE_REMOVED physically removes this property from the applied Log4j configuration.
This capability is useful when simply overriding some properties invalidates other existing properties, which then need to be removed to avoid follow-up issues.
Example:
- Default configuration is
appender.dbglog.type = RollingFile; - To disable it, the property above needs at least to be overridden:
appender.dbglog.type = Null; - If any
RollingFile dependent properties become invalid (e.g., appender.dbglog.filePattern), errors are generated when configuring Log4j; - Setting the property to
TO_BE_REMOVED produces a clean Log4j2-running configuration.
If you want to define a file path to a log file inside FNZ Studio's data home directory, you can use the place holder ${nm.data.home}:
appender.myapp.fileName = ${nm.data.home}/logs/myapp.log