'Does Log4J2 have an equivalent of Log4J's Renderers?

I'm working in a Java solution that is using log4j 2.11 as its logging framework. I'm also using a library that uses a particular POJO extremely frequently. I would like to be able to pass this object directly into a log statement log.debug("POJO: %s", pojo) but sadly this object does not implement toString and I am unable to modify the library code.

From what I've been able to tell, log4j 1.x had a solution to this via ObjectRenderer. You could implement ObjectRenderer and then in your log4j.properties file define a line such as log4j.renderer.com.library.Pojo=com.project.PojoRenderer and then log4j would call your renderer to provide that string value.

According to https://logging.apache.org/log4j/2.x/manual/compatibility.html however it seems this feature did not make it into log4j2. Is there an equivalent feature that I could use to log this directly without having to resort to a wrapper or helper method?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source