I'm new at this logging stuff and i want see logging from spring to see all the beans created.
So I want to try logging with log4j
but no extra loggin appear in the console.
I follow some example to make my logging.
Here's my configuration :
pom.xml
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-rc2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-rc2</version>
</dependency>
log4j.properies
# Root logger option
log4j.rootLogger=INFO, stdout
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.logger.org.springframework=INFO,stdout
My Controller Class
//Import log4j classes.
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
@Transactional
@Controller
public class Inscription {
...
static final Logger logger = LogManager.getLogger(Inscription.class);
...
@RequestMapping(value="/")
public String Test(ModelMap model) {
...
//log it via log4j
logger.debug(model);
...
}
}
is the log4j.property loaded ? (i put it twice to make sure)
what mean this logger.debug(model);
is it requierd to make logging or just log4j.property
is enough ?
I have created a log4j2.xml in
classpath
(src
folder) it will detect automatically by log4j