Rendered Messages in Log4J 2

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Rendered Messages in Log4J 2

Praveen Kumar Gunasekaran
Hi,

During the Log4j2 migration from Log4J 1.2.15, need suggestions on the
below classes,

org.apache.log4j.Category
org.apache.log4j.spi.LoggerRepository
org.apache.log4j.spi.RendererSupport

We use the above classes to handle the Rendered Action and Cause Messages,
for ex:

LoggerRepository repository = category.getLoggerRepository();


if (repository instanceof RendererSupport) {

RendererSupport rs = (RendererSupport)repository;

renderedCauseMessage = rs.getRendererMap().findAndRender(causeMessage);

}

I was not able to find the replacement classes for these objects in Log4J2.

Thanks,
Praveen Kumar
Reply | Threaded
Open this post in threaded view
|

Re: Rendered Messages in Log4J 2

Ralph Goers
Based on what I am seeing of how Log4j 1 makes use of RendererSupport, the equivalent functionality is provided by the Message objects in Log4j 2. Each Message must implement a getFormattedMessage method to render the message contents more or less in the same way that Log4j 1 uses the RendererMap to determine how to Render each Object type.

Ralph

> On Dec 25, 2017, at 11:13 AM, Praveen Kumar Gunasekaran <[hidden email]> wrote:
>
> Hi,
>
> During the Log4j2 migration from Log4J 1.2.15, need suggestions on the
> below classes,
>
> org.apache.log4j.Category
> org.apache.log4j.spi.LoggerRepository
> org.apache.log4j.spi.RendererSupport
>
> We use the above classes to handle the Rendered Action and Cause Messages,
> for ex:
>
> LoggerRepository repository = category.getLoggerRepository();
>
>
> if (repository instanceof RendererSupport) {
>
> RendererSupport rs = (RendererSupport)repository;
>
> renderedCauseMessage = rs.getRendererMap().findAndRender(causeMessage);
>
> }
>
> I was not able to find the replacement classes for these objects in Log4J2.
>
> Thanks,
> Praveen Kumar



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Rendered Messages in Log4J 2

Matt Sicker
Isn't the Category class now called ExtendedLogger?

If you're looking for customization of the log message output, then yes,
the Message API is perfect for this (and would even work with logback or
other logging libraries).

On 25 December 2017 at 13:02, Ralph Goers <[hidden email]>
wrote:

> Based on what I am seeing of how Log4j 1 makes use of RendererSupport, the
> equivalent functionality is provided by the Message objects in Log4j 2.
> Each Message must implement a getFormattedMessage method to render the
> message contents more or less in the same way that Log4j 1 uses the
> RendererMap to determine how to Render each Object type.
>
> Ralph
>
> > On Dec 25, 2017, at 11:13 AM, Praveen Kumar Gunasekaran <
> [hidden email]> wrote:
> >
> > Hi,
> >
> > During the Log4j2 migration from Log4J 1.2.15, need suggestions on the
> > below classes,
> >
> > org.apache.log4j.Category
> > org.apache.log4j.spi.LoggerRepository
> > org.apache.log4j.spi.RendererSupport
> >
> > We use the above classes to handle the Rendered Action and Cause
> Messages,
> > for ex:
> >
> > LoggerRepository repository = category.getLoggerRepository();
> >
> >
> > if (repository instanceof RendererSupport) {
> >
> > RendererSupport rs = (RendererSupport)repository;
> >
> > renderedCauseMessage = rs.getRendererMap().findAndRender(causeMessage);
> >
> > }
> >
> > I was not able to find the replacement classes for these objects in
> Log4J2.
> >
> > Thanks,
> > Praveen Kumar
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Matt Sicker <[hidden email]>