Using java.util.logger with a separate thread to write on file?

后端 未结 3 1203
眼角桃花
眼角桃花 2020-12-19 19:17

I have 2 FileHandlers that write out to two separate files, and the amount of I/O occurring is slowing down my application quite a bit:

  1. I\'ve decided to hav

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-19 19:25

    You can use log4j 2 JDK Logging Adapter to enable logging with log4j, And log4j 2 provide remarkable asynchronous Logging mechanism with lot of configuration options.

    Necessary VM arguments

    -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager
    -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
    

    You can find more information about log4j 2 async logging here and tomcat configuration details here

    sample Log4j2.xml for async loggign

    
      
        
        
          
            %d %p %c{1.} [%t] %m %ex%n
          
        
      
      
        
          
        
      
    
    

提交回复
热议问题