Search code examples
javamavenwarlog4j2

Configurable fileName in RollingRandomAccessFile log4j2.xml


In maven war deployment, is it possible to make log4j2.xml fileName as configurable. Following is my application structure.

enter image description here

Currently the paths are hardcoded in the log4j2.xml file.

enter image description here


Solution

  • Yes, you can use Lookups in the file name that will be evaluated when the configuration is processed. So you can create a file name like “${sys:LOG_DIR:-logs}/app.log”.