I have a following project structure:
XML file log4j.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%-5p | %d{yyyy-MM-dd HH:mm:ss} | [%t] %C{2} (%F:%L) - %m%n"/>
</Console>
<File name="FILE" fileName="C:/Users/...bla-bla-bla.../WebProject/logs/error.log">
<PatternLayout pattern="%-5p | %d{yyyy-MM-dd HH:mm:ss} | [%t] %C{2} (%F:%L) - %m%n"/>
</File>
<File name="INFO" fileName="C:/Users/...bla-bla-bla.../WebProject/logs/info.log">
<PatternLayout pattern="%-5p | %d{yyyy-MM-dd HH:mm:ss} | [%t] %C{2} (%F:%L) - %m%n"/>
<Filters>
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</File>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="FILE" level="error"/>
<AppenderRef ref="INFO" level="info"/>
</Root>
</Loggers>
</Configuration>
In build path I have added log4j 1.2 jre
In code, when I try to write info
private static final Logger log = Logger.getLogger(LoginCommandAction.class.getName());
log.info("User successfully logged in");
Default log:
INFO: User logged in
Why does not this message appear in file or in pattern view in console?
Are additional settings required in Eclipse?
Aucun commentaire:
Enregistrer un commentaire