I have an application that needs to log two different types of messages: application log messages and audit messages. Application log messages match the standard lo4j Logger
perfectly, but there are several required parameters for the audit log.
I think I need to wrap log4j to add the additional required parameters to the debug()
, info()
, etc methods, but I hate the idea of wrapping log4j. Should I:
Logger
class that calls a log4j logger behind the scenese?Logger
class and add "audit log" methods with my required parameters?The "message" of the error
, warn
, etc. methods of a log4j Logger
is an arbitrary object; it doesn't need to be a string. You can create your own "message" class to contain the different parameters. Loggers can append the data differently by using a custom Layout
class for the appender of the audit logger.