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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.