Search code examples
javalog4jnio

Does log4j uses NIO for writing data to file?


It seems to be pretty fast already and i was just wondering if anyone knows if its using NIO. I tried searching the whole source code for NIO (well, its kind of way to search :) lol); but did not hit anything. Also, If its not using NIO; do you think its worthwhile to modify log4j to use NIO also to make it more faster? Any pointers advises and links to some resources would be lot helpful.


Solution

  • Also, If its not using NIO; do you think its worthwhile to modify of log4j to use NIO also to make it more faster?

    No, unless logging is a significant part of your application's activities, in which case there is usually something wrong.

    You seem to be under the impression that NIO 'is faster', but this is not true in general. Just try creating two files, one with standard IO and one with NIO, writing a bunch of data to them and closing them. You'll see the performance hardly differs. NIO will only perform better in certain use cases; most usually the case of many connections.