开发者

How can I disable log4j RollingFileAppender buffering for a demo?

开发者 https://www.devze.com 2022-12-13 01:02 出处:网络
I have a Java programming lab-exerci开发者_JAVA技巧se in a course with students that I\'d like to artificially write to disk in an inefficient manner.What I thought would be a mildly hard-to-find (as

I have a Java programming lab-exerci开发者_JAVA技巧se in a course with students that I'd like to artificially write to disk in an inefficient manner. What I thought would be a mildly hard-to-find (as an exercise) would be having the app's log4j statements writing to disk in an unbuffered fashion. The app intentionally has prolific log statements.

What's the best approach for configuring log4j to use a non-buffered file appender? I'm using RollingFileAppender for now, but I don't care which file appender I ultimately use as long as it writes inefficiently to disk.


FileAppender (and RollingFileAppender since it extends it) has a boolean BufferedIO property as well as BufferSize property (which you can set to 1 or some other low value).

Pick one and enjoy.

0

精彩评论

暂无评论...
验证码 换一张
取 消