Reputation: 615
I have log4j2.properties
file which is used for the application log. Now by using that properties file I need to print the hostname/ip address to the output log file. I do not want to modify application code(java class) for this.
Upvotes: 2
Views: 9692
Reputation: 5813
If you want to print server host name in your web application, then include ${hostName}
in your layout pattern.
For log4j2 properties configuration
, below pattern should print hostname of the server -
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} ${hostName} %level [%t] [%c] [%M] [%l] - %msg%n
Upvotes: 2