freemarker log4j警告
log4j:WARN No appenders could be found for logger (freemarker.cache).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
因为freemarker只依赖了log4j,不支持log4j2,所以必须在classpath中加上log4j.properties,否则就会出现上述警告。
# freemarker专用 Global logging configuration 这个配置是调试用的配置,生产环境要改成INFO或更高级别 log4j.rootLogger=DEBUG, stdout # Console output... log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern= %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
加上后如下:
2020-01-01 12:03:08 [ http-nio-8080-exec-1:0 ] - [ DEBUG ] Couldn‘t find template in cache for "system/login.html"("zh_CN", UTF-8, parsed); will try to load it. 2020-01-01 12:03:08 [ http-nio-8080-exec-1:2 ] - [ DEBUG ] TemplateLoader.findTemplateSource("system/login_zh_CN.html"): Not found 2020-01-01 12:03:08 [ http-nio-8080-exec-1:18 ] - [ DEBUG ] TemplateLoader.findTemplateSource("system/login_zh.html"): Not found 2020-01-01 12:03:08 [ http-nio-8080-exec-1:19 ] - [ DEBUG ] TemplateLoader.findTemplateSource("system/login.html"): Found 2020-01-01 12:03:08 [ http-nio-8080-exec-1:19 ] - [ DEBUG ] Loading template for "system/login.html"("zh_CN", UTF-8, parsed) from "class path resource [templates/system/login.html]" 2020-01-01 12:03:09 [ http-nio-8080-exec-1:142 ] - [ DEBUG ] "system/login.html"("zh_CN", UTF-8, parsed) cached copy not yet stale; using cached.