How to enter the memory buffer and flush the buffer to disk manually?

I use slf4j and logback in my application and use org.slf4j.Logger and RollingFileAppender to write log data to a file. I assume that it uses some buffer output, which flushes the output when the buffer is full.

Now I would like to manually manage the log flash. I would like to write the log data to a memory buffer and explicitly dump it to disk. For instance:

  logger.trace ("trace 1") // write to memory buffer  
 logger.trace ("trace 2") // write to memory buffer 
 logger.trace ("trace 3") // write to memory buffer 
 logger.flush () // flush the buffer to the disk

How can i do this?

+6
source share

All Articles