When using Spring framework, we must use Apache Common Logging to print log in console or binary files. As we known, Spring log configuration can change in the
web.xml when it works on server. But in these series of articles, we try to analyze the Spring core techniques without works on server. So there should have another way to configure log without
web.xml because we want to see the debug informations.
Log4jConfigurer.initLogging() method (has been deprecated in Spring 4.2.1) to initialize log4j from the given file location. Note that we always use Maven to build project, but maven might mash
resources folders to one. Thus we should use
classpath: ,without slash, to represent
resources folder in the project.
Now Apache Commons Logging (JCL) provides thin-wrapper Log implementations for other logging tools, including Log4J. But
Log4jConfigurer.initLogging() calls methods from log4j 1.x. It means that we should add log4j 1.x dependency to make sure that our log configuration file works smoothly.