Does Log4j2 support file inclusion mechanism like Logback does ? This is for including parts of a configuration file from another file (containing appenders, loggers etc.)>
XInclude can be used, but isn't an ideal solution. When using XInclude the include files themselves have to define a single top level element such as Appenders/Loggers/Properties.
Here's an example of how you could use it:
jit %d %-5p [%t] %C{1.} - %m%n
As an example include the log4j2-properties.xml could look like:
%d %-5p [%t] %C{1.} - %m%n
You can make XIncludes optional by using an empty "fallback" block. However in the latest version of log4j2 that is available this results in a warning message coming out of Xerces (since the DefaultErrorHandler is being used by log4j2).