Wiki source code of Logging
Version 7.1 by Ricardo RodrÃguez on 2010/12/13
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{box cssClass="floatinginfobox" title="**Contents**"}}{{toc/}}{{/box}} | ||
2 | |||
3 | XWiki uses Commons Logging for logging. By default XWiki is configured so that Commons Logging uses log4J. XWiki's Log4J configuration is located inside XWiki's JAR (xwiki-core-x.y.jar), in a ##[[log4j.properties>>http://fisheye2.cenqua.com/browse/raw,r=trunk/xwiki/xwiki-platform/core/trunk/src/main/resources/log4j.properties]]## file. XWiki' JAR is itself located in your ##WEB-INF/lib/## directory. | ||
4 | |||
5 | {{info}} | ||
6 | By default XWiki is configured to log everything both on the console and in a xwiki.log file located in the directory from where you have started the JVM. This is usually the directory from where you have started your application server/Servlet container. It's recommended to either start the JVM from a location where it's ok to output the xwiki.log file or to create a custom Log4J configuration as explained below. | ||
7 | {{/info}} | ||
8 | |||
9 | = Using a custom Log4J configuration = | ||
10 | |||
11 | The best solution is to create a new ##log4j.properties## file in your ##WEB-INF/classes## directory. It'll thus override the one from the XWiki JAR. As an example, here's a sample configuration: | ||
12 | |||
13 | {{code language="none"}} | ||
14 | ### Direct log messages to stdout | ||
15 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
16 | log4j.appender.stdout.Target=System.out | ||
17 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
18 | log4j.appender.stdout.layout.ConversionPattern=%d [%X{url}] [%t] %-5p %-30.30c{2} %x - %m %n | ||
19 | |||
20 | ### By default everything that is of warning or severity WARN, ERROR or FATAL is logged both to | ||
21 | ### the console and to the xwiki.log file. | ||
22 | log4j.rootLogger=warn, stdout | ||
23 | |||
24 | ### Hibernate logging options | ||
25 | log4j.logger.org.hibernate=warn | ||
26 | log4j.logger.org.hibernate.SQL=warn | ||
27 | log4j.logger.org.hibernate.type=warn | ||
28 | log4j.logger.org.hibernate.ps.PreparedStatementCache=warn | ||
29 | |||
30 | ### XWiki logging configuration | ||
31 | log4j.logger.org.xwiki=info | ||
32 | log4j.logger.com.xpn.xwiki=warn | ||
33 | log4j.logger.com.xpn.xwiki.render.XWikiRadeoxRenderEngine=warn | ||
34 | log4j.logger.com.xpn.xwiki.store.migration=info | ||
35 | |||
36 | ### Deactive Struts warnings | ||
37 | log4j.logger.org.apache.struts.util.RequestUtils=error | ||
38 | |||
39 | ### Deactivate JGroups warnings | ||
40 | log4j.logger.org.jgroups=error | ||
41 | |||
42 | ## Deactive PDF Export CSS Applier warnings | ||
43 | log4j.logger.info.informatica.doc.style.css.dom=error | ||
44 | log4j.logger.org.apache.fop.layoutmgr.inline.ContentLayoutManager=error | ||
45 | {{/code}} | ||
46 | |||
47 | Refer to Log4J's documentation to understand the settings. As an example, to turn on Hibernate's calls, just set the following: | ||
48 | |||
49 | {{code}} | ||
50 | log4j.logger.org.hibernate.SQL=debug | ||
51 | {{/code}} | ||
52 | |||
53 | = Activating the XWiki monitoring feature = | ||
54 | |||
55 | {{info}} | ||
56 | The monitoring feature is already active in the default configuration. | ||
57 | {{/info}} | ||
58 | |||
59 | XWiki has a feature to monitor times spent in its major components. To activate it, you need to: | ||
60 | |||
61 | * Enable the Monitor plugin by adding/modifying the following plugin definition in the ##xwiki.cfg## configuration file: | ||
62 | |||
63 | {{code language="none"}} | ||
64 | xwiki.plugins=\ | ||
65 | [...] | ||
66 | com.xpn.xwiki.monitor.api.MonitorPlugin | ||
67 | {{/code}} | ||
68 | |||
69 | * Enable it by adding/modifying the following in the ##xwiki.cfg## configuration file: | ||
70 | |||
71 | {{code language="none"}} | ||
72 | xwiki.monitor=1 | ||
73 | {{/code}} | ||
74 | |||
75 | * Since the plugin logs everything under the ##DEBUG## severity you also need to configure Log4J (as described above) by adding the following in ##log4j.properties##: | ||
76 | |||
77 | {{code language="none"}} | ||
78 | log4j.logger.com.xpn.xwiki.monitor=debug | ||
79 | {{/code}} |