Aaaah... now i get it thanks. Kind Regards, Buks
On Thu, 09 Jan 2020, 17:08 Ralph Goers, <ralph.go...@dslextreme.com> wrote: > > > > On Jan 9, 2020, at 6:31 AM, buks...@gmail.com wrote: > > > > Hi Ralph, > > I cant understand where the hook for the PatternConverter would be. > > What do you mean by “hook”? PatternConverters are plugins. If you are > using the PatternLayout and need to wrap the message then the pattern would > look like “%wrapper{%msg}” where wrapper is the key you assigned your > PatternConverter. The RegexReplacementConverter works in a similar fashion. > > You could wrap the whole pattern this way if you want - > “%wrapper{[%-5level] %c{1.} %msg%n}”. The pattern converter doesn’t > actually have to do any conversion. It can call your DAO and then return > the string it was operating on. > > Ralph > > > > > > 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 > >