简体   繁体   中英

In log4j2 Can I Have Multiple Loggers with the Same Name?

In log4j2 is it legal to have multiple loggers with the same name? If it isn't, how would I be able to accomplish the same thing?

<logger name="com.foo.bar" level="error" additivity="false">
    <appender-ref ref="SMTPAppender" /> 
    <appender-ref ref="stdout" />
</logger>
<logger name="com.foo.bar" level="INFO">
    <appender-ref ref="RollingFile"/>
</logger>
<root level="INFO">
    <appender-ref ref="stdout"/>
</root>

This question has already been resolved here: How to configure log4j to log different log levels to different files for the same logger

You must use an appender, as you cannot have two loggers with the same name.

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM