I am trying to append a tag (a string) to every log message at log4j2, and the message will be pass to socket serializedlayout for output. so it that possible to intercept the log message and add some tag (string) to it?
Below is log4j2.xml
<Socket name="LOGSTASH" host="192.168.0.1" port="4567" immediateFlush="true" >
<SerializedLayout />
</Socket>
Below is calling
private static final Logger log = LogManager.getLogger(aClazz.class);
private void aMethod(){
log.error("ooops");
}
Below is origin output
method : aMethod()
class : aClazz
level : error
message : ooops
trace.........
Below is expected output
method : aMethod()
class : aClazz
level : error
message : [Some String] ooops
trace.........