You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2015/12/30 19:11:49 UTC
[29/35] incubator-freemarker git commit: Manual: Adding
cfg.setLogTemplateExceptions(false) to more places.
Manual: Adding cfg.setLogTemplateExceptions(false) to more places.
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/56b5f6e3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/56b5f6e3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/56b5f6e3
Branch: refs/heads/2.3
Commit: 56b5f6e3f7836464bf35f7d145c762fe46c64f45
Parents: 7292716
Author: ddekany <dd...@apache.org>
Authored: Tue Dec 29 11:57:25 2015 +0100
Committer: ddekany <dd...@apache.org>
Committed: Tue Dec 29 11:57:25 2015 +0100
----------------------------------------------------------------------
src/manual/en_US/book.xml | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/56b5f6e3/src/manual/en_US/book.xml
----------------------------------------------------------------------
diff --git a/src/manual/en_US/book.xml b/src/manual/en_US/book.xml
index 9c888d2..092d18b 100644
--- a/src/manual/en_US/book.xml
+++ b/src/manual/en_US/book.xml
@@ -6218,7 +6218,10 @@ cfg.setDefaultEncoding("UTF-8");
// Sets how errors will appear.
// During web page *development* TemplateExceptionHandler.HTML_DEBUG_HANDLER is better.
-cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);</programlisting>
+cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
+
+// Don't log exceptions inside FreeMarker that it will thrown at you anyway:
+cfg.setLogTemplateExceptions(false);</programlisting>
<para>From now you should use this <emphasis>single</emphasis>
configuration instance (i.e., its a singleton). Note however that if a
@@ -6478,6 +6481,7 @@ public class Test {
cfg.setDirectoryForTemplateLoading(new File("<replaceable>/where/you/store/templates</replaceable>"));
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW);
+ cfg.setLogTemplateExceptions(false);
/* ------------------------------------------------------------------------ */
/* You usually do these for MULTIPLE TIMES in the application life-cycle: */
@@ -8708,6 +8712,22 @@ c</programlisting>
</section>
<section>
+ <title>TemplateException logging</title>
+
+ <para>By default FreeMarker <link
+ linkend="pgui_misc_logging">logs</link> all
+ <literal>TemplateException</literal>-s under the
+ <literal>freemarker.runtime</literal> log category, even when it
+ will throw it at you from its public API. As logging has become
+ common practice in Java applications, this usually leads to double
+ logging of exceptions now, so it's recommended to disable this
+ legacy behavior by
+ <literal>cfg.setLogTemplateExceptions(false)</literal> (or
+ <literal>log_template_exceptions=false</literal>) where you
+ configure FreeMarker.</para>
+ </section>
+
+ <section>
<title>Explicit error handling in templates</title>
<para>Although it has nothing to do with the FreeMarker