Log4j conversion template for machine identification

We have a test case that we are developing for an integration test. The idea is to run our code on two machines on an isolated network. We have various log messages set in the code, and this works fine. However, we would like to record interactions from two machines in a common journal so that we can track interactions between them.

To this end, we would like to identify the machine that raised the magazine message. My first thought was that we can do this with conversion templates, but we cannot see the template in the link to achieve this.

I believe that my question has two parts. Firstly, it is possible, and secondly, if not, does the community have any ideas on how we can achieve this.

Many thanks.

Simon

+3
source share
3 answers

AFAIK is not possible with an existing template. My first thought is to use Log4j NDC or MDC . You will need to explicitly specify the host name in one of these contexts for each thread that starts, so this is a bit of a hassle.

+1
source

Consider using a variable

0
source

Linux, SyslogAppender syslog. , SyslogAppender, true.

0

Source: https://habr.com/ru/post/1761126/


All Articles