I change file appender file name in log4j at runtime.
now I want the contents of previous file to be in the new file for the appender.
Can somebody tell me how to do this ?
Initially I have log4j.properties as:
#log4j.appender.H.File='/home/g/connector/logs/'Y'_H.log'
#log4j.appender.H.File=/home/g/connector/logs/H.log
log4j.appender.H.File=/home/g/${logNameSuffix}.log
In my program, I initially do:
Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd.HH:mm:ss");
formattedDate = "jam" + formatter.format(date) + "_" + port;
System.setProperty("logNameSuffix", formattedDate);
PropertyConfigurator.configure(otherArgs[1]);
Then re-load as:
String logName = formattedDate;
System.clearProperty("logNameSuffix");
System.setProperty("logNameSuffix", logName);
LogManager.resetConfiguration();
what i want is that the new log created should get the old log contents also in it.
Is it possible with log4j ?
Thanks, JJ