热门面试题与答案和在线测试
面向面试准备、在线测试、教程与实战练习的学习平台

通过聚焦学习路径、模拟测试和面试实战内容持续提升技能。

WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。

面试准备

Without Book 提问

Review the question and existing answers carefully before replying. The best answers explain the reasoning, steps, and tradeoffs so other learners can benefit too.

问题. log4j.xml or log4j.properties in java log configuration.

- Which one I should prefer - log4j.xml or log4j.properties to configure log in my java app.

发布时间 Jul 23, 2014 发布者 Ruby Singh
回答. Properties can be defined by a properties file or by an XML file. Log4j looks for a file named log4j.xml and then for a file named log4j.properties. Both must be placed in the src folder.

The property file is less verbose than an XML file. The XML requires the log4j.dtd to be placed in the source folder as well. The XML requires a dom4j.jar which might not be included in older Java versions.

The properties file does not support some advanced configuration options like Filters, custom ErrorHandlers and a special type of appenders, i.e. AsyncAppender. ErrorHandlers defines how errors in log4j itself are handled, for example badly configured appenders. Filters are more interesting. From the available filters, I think that the level range filter is really missing for property files.
发布时间 Jul 26, 2014 发布者 Johny Verma

输入你的回答

姓名
邮箱地址
回答
安全验证
继续前请计算: 8 + 3 = ?
版权所有 © 2026,WithoutBook。