I am using jpos 2.1.0 and using JposLogger to generate and rotate iso logs. However i am not able to configure the parameters appropriately due to which neither the logs are rotated based on dates neither i am able to close the open log files.
This is related to the previous issue Too many files open
which i thought was due to issue in using generic packager but while going deeply, it was due to improper closure of files generated by JposLogger, which can be identified using command lsof -p in centos. One file is generated for one request.
[cipsappcen@connectipsappcen local]$ lsof -p 12108 |grep iso.log
java 12108 cipsappcen 36w REG 253,2 58589 405618549 /u03/connectIPSSRVC/log/iso.log
java 12108 cipsappcen 47w REG 253,2 58589 405618549 /u03/connectIPSSRVC/log/iso.log
public class Iso8583MessageBOKImpl implements Iso8583Message{
JposLogger logger = new JposLogger(isoLogLocation);
org.jpos.iso.ISOPackager customPackager = new GenericPackager(isoPackagerLocation+iso8583Properties.getPackager());
BaseChannel channel = new ASCIIChannel(iso8583Properties.getServerIp(), Integer.parseInt(iso8583Properties.getServerPort()), customPackager);// live
logger.jposlogconfig(channel);
...
}
public void jposlogconfig(ISOChannel channel){
try{
//Configuring Logger
Logger logger = new Logger();
logger.setName("Q2");
org.jpos.util.DailyLogListener dayLog = new org.jpos.util.DailyLogListener();
ProtectedLogListener pll = new ProtectedLogListener();
Configuration protectLogCfg = new SimpleConfiguration();
protectLogCfg.put("protect", "2");
pll.setConfiguration(protectLogCfg);
logger.addListener(pll);
Configuration dayLogCfg = new SimpleConfiguration();
dayLogCfg.put("window", "86400");
dayLogCfg.put("prefix", logLocation);
dayLogCfg.put("suffix", ".log");
dayLogCfg.put("date-format", "-yyyy-MM-dd");
dayLog.setConfiguration(dayLogCfg);
logger.addListener(dayLog);
logger.addListener(new SimpleLogListener(System.out));
((LogSource)channel).setLogger(logger, "connectips-channel");
logger.removeListener(pll);
}catch(Exception ex){
System.out.println(ex);
}
}
Since files are not closed properly OS is not able to handle the too many open files.