One idea could be to create a JsonMessage class that implements the org.apache.logging.log4j.message.Message interface.
This class would handle creating the JSON strings for your objects, so your logging code would look like this: logger.log(new JsonMessage(myObject)); Or, if all your appenders are custom appenders, you can extract the original object from your JsonMessage. Note: If you are using async logging the objects wrapped in the custom Message should be immutable or your application thread may modify them while the appender is reading them in another thread. Sent from my iPhone > On 2014/07/23, at 18:40, David KOCH <[email protected]> wrote: > > Hi, > > When I log I do: object_instance -> JSON -> string, > logger.log(<my_json_string_from_object>) in the application only to do the > de-serialisation in each of my custom appenders' append(LogEvent) methods, > followed by appender-specific processing on the de-serialised object. > > I would like to know how can I make the serialisation/de-serialisation > procedure less "manual", like I just call logger.log(<my_Object>) and the > LogEvent processed inside the appender's append method contains the object > inside (<my_class>) LogEvent.getMessage(). > > Thanks, > > David --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
