Does log4j or Logback support memory files?

Do any of these logging libraries support memory mapped files? If not, is there a Java logging library that supports it?


@ paulsm4 I'm talking about java.nio.MappedByteBuffer



source to share

3 answers

I'm not sure what you mean by "memory files" or what exactly you are trying to accomplish.

But one way would be to write your logs to a RAM disk. For example:



Slf4j is not a journal library. This is the facade for the actual library / registration system you are using. So the question is asked for slf4j.

Log4j does not provide an implementation Appender

that is listed as using memory mapped files. It can do it under the hood. You will need to check the source code.

The same applies to the magazine.

AFAIK, there is nothing to prevent you from writing your own Log4j or Logback appender that used the mapped file. It would be interesting to know if there are any performance benefits in doing this. (My guess is no. Memory mapping does make sense for reading and reading / writing files. The log file is only written from the point of view of the application.)



I have implemented an appender in Log4j 2 that writes to mapped files.



All Articles