简体   繁体   中英

log4j: how to output only messages I'm interesting in

When I setup log4j for a class, for example:

private final Logger log = Logger.getLogger(LoginAction.class);

with config

log4j.rootLogger = INFO, abc
log4j.appender.abc = org.apache.log4j.ConsoleAppender
log4j.appender.abc.layout = org.apache.log4j.SimpleLayout

it will output all messagess info and warn even those from framework and something else I'm not interesting in. So, how output only my messages defined in code like:

log.warn("login error: " + email);
log.info("login success: " + email);

log4j.rootLogger = INFO, abclog4j.rootLogger = ERROR, abc并使用日志级别info为您的软件包构建另一个记录器

log4j.logger.<your package>= INFO, abc

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