可以将两个log4j fileappender写入同一文件吗? [英] Can two log4j fileappenders write to the same file?

查看:470
本文介绍了可以将两个log4j fileappender写入同一文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

暂时忘了一个问题,为什么你会做这样的事情-如果出于某种原因,两个FileAppender配置了相同的文件,那么此设置会起作用吗?

Forget for a second the question of why on earth would you do such a thing - if, for whatever reason, two FileAppenders are configured with the same file - will this setup work?

推荐答案

Log4j的FileAppender不允许两个JVM写入同一文件.如果尝试这样做,将会得到损坏的日志文件.但是,在审慎模式中,log4j的后继logback允许两个追加器,即使在不同的方式下也是如此. JVM可以写入同一文件.

Log4j's FileAppender does not allow for two JVM's writing to the same file. If you try, you'll get a corrupt log file. However, logback, log4j's successor, in prudent mode allows two appenders even in different JVMs to write to the same file.

这篇关于可以将两个log4j fileappender写入同一文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆