I want to append hostname and date to the log file name.So log file Name should be like app_hostname.date.log. Note: I need to do this configuration without using any java code. Is that possible?
Currently I am using log4j.properties file to accomplish this where I made the following configuration:
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${catalina.base}/logs/appLogs_${hostName}.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%t] %-5p %c %x - %m%n
Now the problem is I expect the name of the file to be 'appLogs_localhost.log' but it is actually coming like 'appLogs_.log'. Moreover I want to append the date also. Thanks in advance.