Yavor16 commented on issue #2640:
URL: 
https://github.com/apache/logging-log4j2/issues/2640#issuecomment-2154868957

   After the advice I tried to create only one LoggerContext and to close every 
FileAppender after the file has been persisted and the OOM is gone. 
Unfortunately, know I face a new issue. 
   
   java.lang.IllegalStateException: ManagerFactory 
[org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory@48172888]
 unable to create manager for [logs/test.log] with data 
[org.apache.logging.log4j.core.appender.FileManager$FactoryData@3f1853a]
        at 
org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:148)
        at 
org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:112)
        at 
org.apache.logging.log4j.core.appender.FileManager.getFileManager(FileManager.java:225)
        at 
org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:102)
   
   and also:
   
   ERROR Unable to write to stream logs/test.log for appender ... 
org.apache.logging.log4j.core.appender.AppenderLoggingException: Error writing 
to stream logs/test.log
   
   Every step we create new FileAppender that is later closed.
   
   
   File logFile =  new File("test/", fileName);
   FileAppender fileAppender = FileAppender.newBuilder()
                              .setName(loggerName)
                              .withFileName(logFile.toString())
                              .setLayout(layoutCreatorFunction.apply(context))
                              .setConfiguration(context.getConfiguration())
                              .build()
   
   LoggerConfig loggerConfig = loggerContext.getConfiguration()
                               .getLoggerConfig(loggerName);
   
   loggerConfig.setLevel(Level.DEBUG);
   loggerConfig.addAppender(fileAppender, Level.DEBUG, null);
   
   loggerContext.updateLoggers();
   Logger logger = loggerContext.getLogger(loggerName);
   
   
   and than we use the 'logger'
   
   do you why does this occur


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to