Jinjava的详细调试输出使我发疯,并且我不知道如何修改日志记录级别。我在Jinjava github page 或Jinja wiki
上找不到任何内容有人有同样的问题,甚至有更好的解决方案来解决它吗?
我的catalina.out日志充满了将要呈现的调试日志和html模板,这使调试应用程序变得非常困难。
09:40:45.690 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered defined
09:40:45.694 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered divisibleby
09:40:45.695 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered equalto
09:40:45.695 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered even
09:40:45.695 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered iterable
09:40:45.695 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered lower
09:40:45.695 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered mapping
09:40:45.695 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered none
09:40:45.696 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered number
09:40:45.696 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered odd
09:40:45.696 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered sameas
09:40:45.696 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered sequence
09:40:45.696 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered string
09:40:45.696 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered string_containing
09:40:45.697 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered string_startingwith
09:40:45.697 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered truthy
09:40:45.697 [http-nio-127.0.0.1-8888-exec-12] DEBUG jinjava - ExpTestLibrary: Registered undefined
09:40:45.712 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered none
09:40:45.712 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered number
09:40:45.712 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered odd
09:40:45.712 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered sameas
09:40:45.712 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered sequence
09:40:45.712 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered string
09:40:45.712 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered string_containing
09:40:45.713 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered string_startingwith
09:40:45.713 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered truthy
09:40:45.713 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered undefined
09:40:45.713 [http-nio-127.0.0.1-8888-exec-9] DEBUG jinjava - ExpTestLibrary: Registered upper
09:40:45.711 [http-nio-127.0.0.1-8888-exec-1] DEBUG jinjava - ExpTestLibrary: Registered defined
09:40:45.714 [http-nio-127.0.0.1-8888-exec-1] DEBUG jinjava - ExpTestLibrary: Registered divisibleby
<li class="sidebar-brand bg-white">
<h4 class="text-left">
<a id="sidebar-title" href="#">
Latest Achievements
</a>
</h4>
<!--<div class="dummy">-->
<!--<img src="assets/dummy/snippet_achievements.png" width="100%" height=""/>-->
<!--</div>-->
<!-- Badge -->
{% if badges|length > 0 %}
{% for name, image in badges.items() %}
<div class="dummy">
<img src={{ image }} width="100%" height=""/>
<div>{{ name }}</div>
</div>
{% endfor %}
{% endif %}
<!-- END Badge -->
<div class="text-right textlink">
<a onclick=""">show all
<img src="assets/arrow_blue.svg" width="24px" height="24px"/>
</a>
</div>
</li>
</ul>
感谢我可能错过的任何提示或链接。
PS:现在我写了这篇文章,我意识到Tomcat的日志记录级别可能会捕获所有这些消息并将其转储到日志文件中。我仍在发布问题,并将跟进我的发现。他们对将来的其他人可能会有所帮助。
在Jersey documentation之后(以编程方式)启用日志记录,我使用以下代码段配置了日志记录:
register(new LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME),
Level.WARNING, LoggingFeature.Verbosity.HEADERS_ONLY, Integer.MAX_VALUE));
我还确保Tomcat的logging.properties文件中的所有Level语句都至少设置为“ INFO”。
1catalina.org.apache.juli.AsyncFileHandler.level = INFO
但是Jersey DEBUG日志仍然出现在服务器日志文件中。
注意:我正在为应用程序使用专用日志文件,并且JinJava日志没有出现。这证实了我的假设,即Tomcat的日志级别设置较低,可以打印JinJava语句。目前还可以,但我将做进一步的研究和测试以防止这种情况。
File contextLogFile = new File(filePath.toString());
FileHandler handler = new FileHandler(contextLogFile.getPath());
handler.setLevel(Level.INFO);
handler.setFormatter(new SimpleFormatter());
logger.addHandler(handler);
register(new LoggingFeature(logger, LoggingFeature.Verbosity.HEADERS_ONLY, Integer.MAX_VALUE));