Search code examples
javadependencieslog4jappender

Dependency among log4j appenders


I'm writing a custom log4j appender, and I want to rely on another configured appender as a fallback, in case my (Database) appender fails.

How can I guarantee order of construction of the appenders? My appender's activateOptions() method tries to access another appender and fails because it's not constructed/registered yet.


Solution

  • I suggest to move/copy the config options for the second appender into the config of your custom appender and then create the second appender yourself inside of your custom appender.