How can I use log4j2 to log messages into a Jenkins pipeline job console output (while the job is running)?

How can I use log4j2 to log messages into a Jenkins pipeline job console output (while the job is running)?

This should help:

https://wiki.jenkins.io/display/JENKINS/Logging

And here is a good place to get more help with Jenkins:

@wreed , i tried this earlier , but didn’t able to understand what exactly need to change while configuring, log4j2 is working fine in my machine and getting log4j2 logs on console, but not getting logs on jenkins, can you brief me about this.

Thanks in Advance.