Author Topic: Log4j2 and the LMS logging framework issue  (Read 163 times)

Offline kellogs

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Log4j2 and the LMS logging framework issue
« on: March 16, 2019, 07:40:36 PM »
Hello,

I am new to Genesys altogether.
Has anyone succeeded with the new logging framework ?
I am having no luck with the segments and expire options. They just are not accounted for:

Code: [Select]
KeyValueCollection logSection = new KeyValueCollection();
         logSection.addString("verbose", "all");
         logSection.addString("all", "logfile.log, stdout");
         logSection.addString("expire", "2 file");
         logSection.addString("segment", "1000 KB");
//         logSection.addString("log-file-size", "1000 kB");
//         logSection.addString("buffer", "false");
         
         KeyValueCollection logSection2 = new KeyValueCollection();
         logSection2.addObject("log", logSection);
       
         GApplicationConfiguration gaAppConf = new GApplicationConfiguration();
         gaAppConf.setOptions(logSection2);
       
    lmsMessageConveyor = LmsMessageConveyor.newBuilder().addLmsEnum(CommonLmsEnum.class).build();
    Log4j2LmsLoggerFactory.setLoggerFactoryImpl(Log.LOG_FACTORY_LOG4J2, lmsMessageConveyor);
    boolean mkay = Log4j2Configurator.applyLoggingConfig(gaAppConf, lmsMessageConveyor);
//    LmsLoggerFactory logFact = Log4j2LmsLoggerFactory.createInstance(lmsMessageConveyor);
//    LOG = logFact.getLmsLogger(AppManager.class);
    LOG = Log4j2LmsLoggerFactory.getLogger(AppManager.class);
   
//    lmsLoggerFactory = LmsLoggerFactory.createInstance(lmsMessageConveyor);
//    LOG = lmsLoggerFactory.getLmsLogger(AppManager.class);
//    LOG = LmsLoggerFactory.getLogger(AppManager.class);
//        PsdkCustomization.setOption(PsdkCustomization.PsdkOption.PsdkLoggerTraceMessages, "true");
        for (int i = 0; i < 25000; i++)
        LOG.info(CommonLmsEnum.GCTI_APP_INIT_COMPLETED);

This produces > 1MB of logs and the file just continues to grow instead of getting split at the1000 kB mark.

If instead of         

Code: [Select]
logSection.addString("all", "logfile.log, stdout");
I put

Code: [Select]
logSection.addString("all", "logfile.log");
there is no more console output, so I know the settings are being applied. Tried with log4j2 versions from 2.7 to 2.11.2 - same thing.

Is this a know issue ? Should I go back to the deprecated logging framework instead ?

Thank you!