Can you write a custom layout which wraps another layout and implements that code on the result? Encapsulation should be easier to support than extension.
-ck > On Jan 9, 2020, at 8:31 AM, buks...@gmail.com wrote: > > Hi Ralph, > I cant understand where the hook for the PatternConverter would be. > > My override is: > private void tryAppend(final LogEvent event) throws ExecutionException, > InterruptedException, TimeoutException { > > final Layout<? extends Serializable> layout = getLayout(); > String logMessage = (String)layout.toSerializable(event); > BuildProperties buildProperties = > (BuildProperties) > AppContext.getApplicationContext().getBean(BuildProperties.class); > LogViewerDao logViewerDao = new LogViewerDao(buildProperties, event, > logMessage); > manager.send(logViewerDao.toJson().getBytes()); > } > > The 2.10 version has: > private void tryAppend(final LogEvent event) throws ExecutionException, > InterruptedException, TimeoutException { > final Layout<? extends Serializable> layout = getLayout(); > byte[] data; > if (layout instanceof SerializedLayout) { > final byte[] header = layout.getHeader(); > final byte[] body = layout.toByteArray(event); > data = new byte[header.length + body.length]; > System.arraycopy(header, 0, data, 0, header.length); > System.arraycopy(body, 0, data, header.length, body.length); > } else { > data = layout.toByteArray(event); > } > manager.send(data); > } > > Even here the layout is resolved and directly after that sent to the > KafkaManager. > In my version I need some action between where the layout data is embedded as > an attribute in another object; > > Kind Regards, > Buks > > -----Original Message----- > From: Ralph Goers <ralph.go...@dslextreme.com> > Sent: Wednesday, 08 January 2020 17:23 > To: Log4J Users List <log4j-user@logging.apache.org> > Subject: Re: Need to override the Append method of the KafkaAppender > > If you need to wrap the message then you should create a pattern converter. > > Ralph > >> On Jan 8, 2020, at 5:23 AM, Buks van der Lingen <buks...@gmail.com> wrote: >> >> Hi, >> I have a need to wrap the message created by the PatternLayout assigned to >> my KafkaAppender and pass that to the KafkaManager. >> >> The wrapper contains Spring-Boot environment/Build and other properties. >> >> The KafkaManager is private in the appender and I can’t get around the >> implementation at append(); For now I duplicated the KafkaAppender and >> just added the functionality I need in append(); >> >> If anyone has a better idea pls advise? >> >> Kind Regards, >> Buks >> >> Sent from Mail for Windows 10 >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org