morciuch 2003/07/25 21:36:59
Modified: docs/site changes.html code-standards.html config_guide.html
src/java/org/apache/jetspeed/services/logging
JetspeedLogFactoryService.java
webapp/WEB-INF/conf log4j.properties
xdocs code-standards.xml config_guide.xml
Added: webapp/WEB-INF/conf log4j.xml
Log:
Remaining patches by Harald Ommang for the new logging service (see Bugzilla bug#
19906).
Revision Changes Path
1.155 +1 -3 jakarta-jetspeed/docs/site/changes.html
Index: changes.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/docs/site/changes.html,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -r1.154 -r1.155
--- changes.html 17 Jul 2003 00:16:21 -0000 1.154
+++ changes.html 26 Jul 2003 04:36:58 -0000 1.155
@@ -5,7 +5,6 @@
<!-- start the processing -->
<!-- ====================================================================== -->
- <!-- GENERATED FILE, DO NOT EDIT, EDIT THE XML FILE IN xdocs INSTEAD! -->
<!-- Main Page Section -->
<!-- ====================================================================== -->
<html>
@@ -15,7 +14,6 @@
-
<title>Jetspeed - Jetspeed Changes Log</title>
</head>
@@ -1028,7 +1026,7 @@
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
- Copyright © 1999-2003, Apache Software Foundation
+ Copyright © 1999-2002, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
1.34 +71 -10 jakarta-jetspeed/docs/site/code-standards.html
Index: code-standards.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/docs/site/code-standards.html,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- code-standards.html 10 Jun 2003 16:09:22 -0000 1.33
+++ code-standards.html 26 Jul 2003 04:36:58 -0000 1.34
@@ -710,16 +710,58 @@
<tr><td>
<blockquote>
<p>
- In general logging should be kept to a minimum. Logging is very usefully
- for diagnosing and resolving problems. Error message should describe the
+ Logging is very useful for diagnosing and resolving problems. As a general
rule, all exceptions should be logged,
+ and done so in the following fashion: <br />
+ <code>logger.error("What went wrong", ex);</code> <br />
+ This way, both your message and a stack trace of the exception will be
logged. Your error message should describe the
error, and where practical the cause and suggested solutions.
+ Do not log exceptions like this: <code>logger.error(ex);</code> Whenever you
want to log a Throwable, it should be the
+ second parameter of your fatal/error/warn/info/debug call.
+ </p>
+ <p>
+ Since the new logging scheme uses Log4J, the penalty of log statements that
are not actually activated, such as debug,
+ is negligable. However, if your log message uses String concatenation ("+"),
avoid loads of objects to be garbage collected by always
+ checking if the particular level you are logging is enabled, by calling eg.
<code>logger.isDebugEnabled()</code>.
+ This is not necessary for logging simple Strings. Also, if you are building
your message by concatenation, use
+ StringBuffer and .append() instead of String and "+". Your code will be more
efficient and produce less garbage.
</p>
<p>
Debug logging is intended for development and problem determination. It
- is not intended for use in a "normal" production environment. In part
- because of the resource, including CPU and disk space, required. So use
- <code>Log.getLogger().isDebugEnabled()</code> to determine if debug
- logging is enable before generating the debug message.
+ is not intended for use in a "normal" production environment. Therefore do
not depend on important
+ information to be logged using debug. Do, however, add a reasonable about of
debug logging in your code, expecially where
+ robustness checks fail and "strange" things happen. This makes bug hunting a
lot easier! <br />
+ Do NOT use levels above debug, such as info, for debug messages!
+ </p>
+ <div align="left">
+ <table cellspacing="4" cellpadding="0" border="0">
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#ffffff"><pre>
+if (logger.isDebugEnabled())
+{
+ StringBuffer msg = New StringBuffer("accessing rundata ");
+ mgs.append(m_runDataStore.get(Thread.currentThread());
+ msg.append(" for thread: ");
+ msg.append(Thread.currentThread());
+ logger.debug(msg.toString());
+}
+</pre></td>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ </table>
+ </div>
+ <p>
+ The following code snippet shows how to use the new logging features.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
@@ -731,12 +773,31 @@
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
-if (Log.getLogger().isDebugEnabled())
+package mypackage;
+// The two imports needed
+import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
+import org.apache.jetspeed.services.logging.JetspeedLogger;
+
+class MyClass
{
- Log.debug("JetspeedRunDataService: accessing rundata "
- + m_runDataStore.get(Thread.currentThread())
- + " for thread: " + Thread.currentThread());
+ /**
+ * Static initialization of the logger for this class
+ */
+ private static final JetspeedLogger logger =
JetspeedLogFactoryService.getLogger(MyClass.class.getName());
+
+ /**
+ * Some method
+ */
+ someMethod()
+ {
+
+ ...
+ logger.debug("This message should be logged");
+
+ }
+
}
+
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
1.31 +244 -503 jakarta-jetspeed/docs/site/config_guide.html
Index: config_guide.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/docs/site/config_guide.html,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- config_guide.html 1 Jul 2003 15:09:01 -0000 1.30
+++ config_guide.html 26 Jul 2003 04:36:58 -0000 1.31
@@ -524,401 +524,60 @@
<tr><td>
<blockquote>
<p>
- Jetspeed utilizes the logging services provided by Turbine. The logfile(s)
are
+ As og 1.4b5, Jetspeed Log4J for logging. The logfile(s) are
a valuable tool in trouble shooting problems and monitoring the general
health of
Jetspeed an it's portlets.
</p>
<p>
+ The base configuration of the logging is set in the settings in
JetspeedResources.properties shown below.
+ The details of the configuration is done in the file specified by
log4j.properties.
+ The way Jetspeed logs, you are able to controlled logging very detailed, if
you should need so.
+ Jetspeed defines a named logger for every single class that performs
logging. Thus, you can configure it so
+ that a single class logs debug to its own file. This level of detail gives
you better control when debugging!
+ The configuration shipped with Jetspeed is set up on a much coarser level
initially.</p>
+ <div align="left">
+ <table cellspacing="4" cellpadding="0" border="0">
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#ffffff"><pre>
+#########################################
+# JetspeedLogFactory Service #
+#########################################
+# If this file has extension properties, then log4j property configuration is done.
+# Otherwise DOM configuration for XML. Thus you can choose what format you like to
use.
+log4j.properties=/WEB-INF/conf/log4j.properties
+# If true, Log4J will monitor the property file and reconfigure if changed.
+log4j.configureAndWatch=true
+# Number of ms between each property file check
+log4j.watchInterval=60000
+</pre></td>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ </table>
+ </div>
+ <p>
The logging level should be set according the the current needs. DEBUG
logging is
suggested during portlet testing, while INFO logging is appropriate for
every-day
- activity in a stable environment.
+ activity in a stable environment. In heavy production systems, WARN is
appropriate.
</p>
<p>
- Not all of Turbine's logging services are included. Additional
documentation can
- be found at <a
href="http://jakarta.apache.org/turbine">http://jakarta.apache.org/turbine</a>.
+ Detailed information on Log4J canbe found at
+ <a
href="http://jakarta.apache.org/log4j">http://jakarta.apache.org/log4j</a>.
</p>
- <table>
- <tr>
- <td bgcolor="#039acc" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Facility
- </font>
-</td>
- <td bgcolor="#039acc" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Description
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- rotation
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- Rotation of log files. This will limit the amount of disk space
- consumed by the log file. Not supported by all loggers. To enable this
- logger, you must replace "logforj" with "rotation" on the facilities
list
- and set default logger to "rotation". Please check log4j documentation
- for information on various appenders that can be used here (i.e.
- RollingFileAppender vs. DailyRollingFileAppender).
-
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- debug
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- This logger sends log messages to both console and log file. It is
useful
- for testing and debugging but is not appropriate for production use.
- To enable this logger, you must add "debug" to the facilities list
- and set default logger to "debug".
-
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- schedule
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- A facility for the scheduler service
- To disable started/stopped messages set the level to ERROR
-
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- security
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- A facility for security audit. NOTE! As of 23 Jan 2001
- Turbine does not have any standard security auditing
- functionality. It's up to your application.
-
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- system
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- A facility for system logging.
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- sql
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- A facility for SQL query logging
- To enable SQL query logging, set the level to DEBUG
-
- </font>
-</td>
- </tr>
- </table>
<br />
<table border="0"
cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
- <a name="FileLogger"><strong>FileLogger</strong></a>
- </font>
- </td></tr>
- <tr><td>
- <blockquote>
- <p>
- This is a logging service provide with Turbine.
- </p>
- <p>
- Additional information can be found at <a
href="http://jakarta.apache.org/turbine">
- http://jakarta.apache.org/turbine</a>
- </p>
- <table>
- <tr>
- <td bgcolor="#039acc" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Facility
- </font>
-</td>
- <td bgcolor="#039acc" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Description
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- destination.file
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Name of the log file relative to <jetspeed-home>
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- className
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- org.apache.turbine.services.logging.FileLogger
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- level
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- <table>
- <tr>
- <th>Value</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>ERROR</td>
- <td>Designates error events that might still allow the
application to continue running</td>
- </tr>
- <tr>
- <td>WARN</td>
- <td>Designates potentially harmful situations</td>
- </tr>
- <tr>
- <td>INFO</td>
- <td>Designates informational messages that highlight the progress
of the application at course-grained level.</td>
- </tr>
- <tr>
- <td>DEBUG</td>
- <td>Designates fine-grained informational events that are most
useful to debug an application</td>
- </tr>
- </table>
-
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- destination.console
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Optional, default = false <br />
- <table>
- <tr>
- <th>Value</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>false</td>
- <td>message will NOT be sent to the console</td>
- </tr>
- <tr>
- <td>true</td>
- <td>message will ALSO be sent to the console</td>
- </tr>
- </table>
-
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- </font>
-</td>
- </tr>
- </table>
- </blockquote>
- </td></tr>
- <tr><td><br/></td></tr>
- </table>
- <table border="0"
cellspacing="0" cellpadding="2" width="100%">
- <tr><td bgcolor="#828DA6">
- <font color="#ffffff" face="arial,helvetica,sanserif">
- <a name="Log4JavaLoggger"><strong>Log4JavaLoggger</strong></a>
- </font>
- </td></tr>
- <tr><td>
- <blockquote>
- <p>
- This is a more functional logging service that can interact with
operating specific
- facilities like UNIX's syslog and Window's Event Logger
- </p>
- <p>
- Additional information can be found at <a
href="http://jakarta.apache.org/log4j">
- http://jakarta.apache.org/log4j</a> and <a
href="http://jakarta.apache.org/turbine">
- http://jakarta.apache.org/turbine</a>
- </p>
- <p>
- Configuration notes:
- <ul>
- <li>
- All loggers define in <tt>services.LoggingService.facilities</tt>
must
- be the same type when using the Log4J services.
- </li>
- <li>
- When using log file rotation, the rotation facility must be the first
in the
- <tt>services.LoggingService.facilities</tt> list and should replace
the logforj
- facility.
- </li>
- </ul>
- </p>
- <table>
- <tr>
- <td bgcolor="#039acc" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Facility
- </font>
-</td>
- <td bgcolor="#039acc" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Description
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- destination.file
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Name of the log file relative to <jetspeed-home>
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- className
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- org.apache.turbine.services.logging.Log4JavaLogger
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- level
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- <table>
- <tr>
- <th>Value</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>FATAL</td>
- <td>Designates very severe error events that will presumably lead
the application to abort.</td>
- </tr>
- <tr>
- <td>ERROR</td>
- <td>Designates error events that might still allow the
application to continue running</td>
- </tr>
- <tr>
- <td>WARN</td>
- <td>Designates potentially harmful situations</td>
- </tr>
- <tr>
- <td>INFO</td>
- <td>Designates informational messages that highlight the progress
of the application at coarse-grained level.</td>
- </tr>
- <tr>
- <td>DEBUG</td>
- <td>Designates fine-grained informational events that are most
useful to debug an application</td>
- </tr>
- </table>
-
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- MaxFileSize
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Approximate log file size in bytes. 1MB = 1048576 bytes
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- MaxBackupIndex
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
-
- Number of backup log files to maintain. The actual number of log
files
- will be file.backups + 1.
-
- </font>
-</td>
- </tr>
- </table>
- </blockquote>
- </td></tr>
- <tr><td><br/></td></tr>
- </table>
- <table border="0"
cellspacing="0" cellpadding="2" width="100%">
- <tr><td bgcolor="#828DA6">
- <font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Portlet usage logger"><strong>Portlet usage logger</strong></a>
</font>
</td></tr>
@@ -959,18 +618,6 @@
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
- services.PortletStats.logger = access
- </font>
-</td>
- <td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Name of the log4j logger
- </font>
-</td>
- </tr>
- <tr>
- <td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top"
align="left">
- <font color="#000000" size="-1" face="arial,helvetica,sanserif">
services.PortletStats.enabled = false
</font>
</td>
@@ -1005,6 +652,11 @@
</td>
</tr>
</table>
+ <p>
+ NOTE: In addition, the category/logger named
"org.apache.jetspeed.services.portletstats.JetspeedPortletStatsService"
+ in the Log4J configuration controls where the actual logging goes. This
must be set to log at level INFO for
+ the portlet usage logger to be active.
+ </p>
</blockquote>
</td></tr>
<tr><td><br/></td></tr>
@@ -1018,8 +670,10 @@
<tr><td>
<blockquote>
<p>
- The following configuration will rotate the logging among 6 files. All
logging
- will be at the DEBUG level.
+ The following configuration will log all general Jetspeed log to one
file, all Jetspeed services to one, and all
+ logging from turbine to a third. In addition, the neccesary logger for
the portlet usage is defined.<br />
+ NOTE: If you remove the "{1}" behind the %c in the patterns in the
configuration, you will get tha fully
+ qualified class name (i.e. including package name) in the log file. This
might be useful.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
@@ -1032,117 +686,204 @@
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
# -------------------------------------------------------------------
+#
+# This file contains log4j-specifc logging properties. This file is
+# loaded by the logging service based on the following property
+# in JetspeedResources.properties:
#
-# L O G S
+# log4j.properties = ${webappRoot}/WEB-INF/conf/log4j.properties
#
-# -------------------------------------------------------------------
-# This is the configuration for the logging system. In most cases
-# you don't need to modify anything. However, if you wish to add more
-# facilities or modify the existing settings, then you can do so.
+# Appender specified in log4j.category.default must be the same as
+# the one specified in services.LoggingService.default property.
+#
+# All log4j properties should be supported. Check log4j documentation
+# for more information.
+#
+# Note that strings containing "," (comma) characters must backslash
+# escape the comma (i.e. '\,')
#
-# destination.file: A path relative to the web app root
# -------------------------------------------------------------------
-services.LoggingService.facilities=logforj,access
-services.LoggingService.default=logforj
-services.LoggingService.loggingConfig=org.apache.turbine.services.logging.PropertiesLoggingConfig
-
-# A facility for system logging.
-services.LoggingService.system.destination.file=/WEB-INF/log/jetspeed.log
-services.LoggingService.system.className=org.apache.turbine.services.logging.FileLogger
-services.LoggingService.system.level=DEBUG
-
-# A facility for the scheduler service
-# To disable started/stopped messages set the level to ERROR
-services.LoggingService.scheduler.destination.file=/WEB-INF/log/jetspeed.log
-services.LoggingService.scheduler.className=org.apache.turbine.services.logging.FileLogger
-services.LoggingService.scheduler.level=DEBUG
-
-# A facility for debugging applications. Messages will go both
-# to the log file and the server console.
-services.LoggingService.debug.destination.file=/WEB-INF/log/jetspeed.log
-services.LoggingService.debug.destination.console=true
-services.LoggingService.debug.className=org.apache.turbine.services.logging.FileLogger
-services.LoggingService.debug.level=DEBUG
-
-# A facility for SQL query logging
-# To enable SQL query logging, set the level to DEBUG
-services.LoggingService.sql.destination.file=/WEB-INF/log/jetspeed.log
-services.LoggingService.sql.className=org.apache.turbine.services.logging.FileLogger
-services.LoggingService.sql.level=DEBUG
-
-# A facility for security audit. NOTE! As of 23 Jan 2001
-# Turbine does not have any standard security auditing
-# functionality. It's up to your application.
-services.LoggingService.security.destination.file=/WEB-INF/log/jetspeed.log
-services.LoggingService.security.className=org.apache.turbine.services.logging.FileLogger
-services.LoggingService.security.level=DEBUG
-
-# An example configuration for using Log4Java, with log4j properties inline
-# The category name - at the end of this line - needs to match the logging facility
name - the first log4j.
-# need this rootCategory entry to capture the torque/fulcrum etc logging
-services.LoggingService.logforj.log4j.rootCategory = INFO, logforj
-
-# need this category entry for the actual jetspeed logging (I don't know why it
doesn't get covered by the root category!)
-services.LoggingService.logforj.log4j.category.logforj = DEBUG, logforj
-
-services.LoggingService.logforj.log4j.appender.logforj.file
=${webappRoot}/WEB-INF/log/jetspeed.log
-services.LoggingService.logforj.log4j.appender.logforj =
org.apache.log4j.FileAppender
-services.LoggingService.logforj.log4j.appender.logforj.layout =
org.apache.log4j.PatternLayout
-services.LoggingService.logforj.log4j.appender.logforj.layout.conversionPattern =
[%d{dd MMM yyyy HH:mm:ss} %5p] - %m%n
-services.LoggingService.logforj.log4j.appender.logforj.append = false
-services.LoggingService.logforj.className=org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.logforj.level=DEBUG
-
-# An example configuration for portlet access audit logging
-services.LoggingService.access.log4j.category.access = INFO, access
-services.LoggingService.access.log4j.appender.access = org.apache.log4j.FileAppender
-services.LoggingService.access.log4j.appender.access.layout =
org.apache.log4j.PatternLayout
-services.LoggingService.access.log4j.appender.access.layout.ConversionPattern = %m%n
-services.LoggingService.access.log4j.appender.access.append = true
-services.LoggingService.access.log4j.appender.access.file =
${webappRoot}/WEB-INF/log/access.log
-services.LoggingService.access.className =
org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.access.level = INFO
-
-# An example configuration for automatic log rotation using Log4Java
-# This will keep the log file size under 1MB and save up to 5 backup copies
-services.LoggingService.rotation.log4j.rootCategory = INFO, rotation
-services.LoggingService.rotation.log4j.category.rotation = DEBUG, rotation
-
-services.LoggingService.rotation.log4j.appender.rotation.file =
${webappRoot}/WEB-INF/log/jetspeed.log
-services.LoggingService.rotation.log4j.appender.rotation =
org.apache.log4j.RollingFileAppender
-services.LoggingService.rotation.log4j.appender.rotation.layout =
org.apache.log4j.PatternLayout
-services.LoggingService.rotation.log4j.appender.rotation.layout.conversionPattern =
[%d{dd MMM yyyy HH:mm:ss} %5p] - %m%n
-services.LoggingService.rotation.log4j.appender.rotation.append = false
-services.LoggingService.rotation.log4j.appender.rotation.MaxFileSize = 1024KB
-services.LoggingService.rotation.log4j.appender.rotation.MaxBackupIndex = 5
-services.LoggingService.rotation.className =
org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.rotation.level = DEBUG
-
-# An example configuration for using *NIX syslogd with Log4Java
-services.LoggingService.syslog.destination.syslogd.host=my.syslog.server.com
-services.LoggingService.syslog.destination.syslogd.facility=LOG_DAEMON
-services.LoggingService.syslog.className=org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.syslog.level=INFO
-
-# An example configuration for using remote Log4Java server
-services.LoggingService.remote.destination.remote.host=my.remote.server.com
-services.LoggingService.remote.destination.remote.port=1099
-services.LoggingService.remote.className=org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.remote.level=INFO
-
-# An example configuration for sending error reports as email with Log4Java
-# notes:
-# * uses 'mail.server' as SMTP server to send mail through
-# * log4j will send the email when an ERROR is logged, with
-# 'buffer.size' previous (non-ERROR) logs included in the email
-# * configured to log to a file as well otherwise stacktraces are lost
-services.LoggingService.email.destination.file=/WEB-INF/log/jetspeed.log
[EMAIL PROTECTED]
[EMAIL PROTECTED]
-services.LoggingService.email.destination.email.subject=Jetspeed Error Report
-services.LoggingService.email.destination.email.buffer.size=512
-services.LoggingService.email.className=org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.email.level=INFO
+# The rootlogger means that all logging not defined otherwise, will go where it
describes
+log4j.rootLogger = INFO, jetspeed
+# If debug = true, you will see how Log4J configures on the stdout of your webapp
container
+log4j.debug = true
+#
+# Jetspeed goes into Jetspeed Log
+#
+log4j.category.org.apache.jetspeed = DEBUG, jetspeed
+log4j.additivity.org.apache.jetspeed = false
+
+#
+# Jetspeed services goes into Jetspeed Services Log
+#
+log4j.category.org.apache.jetspeed.services = DEBUG, jetspeedsrv
+log4j.additivity.org.apache.jetspeed.services = false
+# Setting CastorPsmlManagerService to higher level, as it is quite verbose on DEBUG
+log4j.category.org.apache.jetspeed.services.psmlmanager.CastorPsmlManagerService =
INFO, jetspeedsrv
+log4j.additivity.org.apache.jetspeed.services.psmlmanager.CastorPsmlManagerService
= false
+
+#
+# Turbine goes into Turbine Log
+# JetspeedLoggingService handles all logging thru TurbineLoggingService
+#
+log4j.category.org.apache.jetspeed.services.logging.JetspeedLoggingService = INFO,
turbine
+log4j.additivity.org.apache.jetspeed.services.logging.JetspeedLoggingService = false
+
+#
+# Portlet access Category
+#
+log4j.category.org.apache.jetspeed.services.portletstats.JetspeedPortletStatsService
= INFO, access
+log4j.additivity.org.apache.jetspeed.services.portletstats.JetspeedPortletStatsService
= false
+
+#
+# Console output Category
+#
+log4j.category.stdout = INFO, stdout
+log4j.additivity.stdout = false
+
+########################################################################
+#
+# Logfile definitions
+#
+########################################################################
+
+#
+# jetspeed.log
+#
+log4j.appender.jetspeed = org.apache.log4j.FileAppender
+log4j.appender.jetspeed.file = ${webappRoot}/WEB-INF/log/jetspeed.log
+log4j.appender.jetspeed.layout = org.apache.log4j.PatternLayout
+log4j.appender.jetspeed.layout.conversionPattern = %d [%t] %-5p %c{1} - %m%n
+log4j.appender.jetspeed.append = false
+
+log4j.appender.jetspeedsrv = org.apache.log4j.FileAppender
+log4j.appender.jetspeedsrv.file = ${webappRoot}/WEB-INF/log/jetspeedservices.log
+log4j.appender.jetspeedsrv.layout = org.apache.log4j.PatternLayout
+log4j.appender.jetspeedsrv.layout.conversionPattern = %d [%t] %-5p %c{1} - %m%n
+log4j.appender.jetspeedsrv.append = false
+
+#log4j.appender.jetspeed = org.apache.log4j.RollingFileAppender
+#log4j.appender.jetspeed.file = ${webappRoot}/WEB-INF/log/rotation.log
+#log4j.appender.jetspeed.MaxFileSize = 50KB
+#log4j.appender.jetspeed.MaxBackupIndex = 5
+#log4j.appender.jetspeed.layout = org.apache.log4j.PatternLayout
+#log4j.appender.jetspeed.layout.ConversionPattern = [%d{dd MMM yyyy HH:mm:ss} %5p]
- %m%n
+
+#
+# turbine.log
+#
+log4j.appender.turbine = org.apache.log4j.FileAppender
+log4j.appender.turbine.file = ${webappRoot}/WEB-INF/log/turbine.log
+log4j.appender.turbine.layout = org.apache.log4j.PatternLayout
+log4j.appender.turbine.layout.conversionPattern = %d [%t] %-5p %c{1} - %m%n
+log4j.appender.turbine.append = false
+
+#
+# Portlet access Output
+#
+log4j.appender.access = org.apache.log4j.FileAppender
+log4j.appender.access.file = ${webappRoot}/WEB-INF/log/access.log
+log4j.appender.access.layout = org.apache.log4j.PatternLayout
+log4j.appender.access.layout.conversionPattern = %m%n
+log4j.appender.access.append = true
+
+#
+# Console Output
+#
+log4j.appender.stdout = org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern = [%d{dd MMM yyyy HH:mm:ss} %5p] -
%m%n
+
+</pre></td>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ </table>
+ </div>
+ <p>
+ The following XML configuration shows a similar configuration in XML
format. You can choose
+ your favorite format.
+ </p>
+ <div align="left">
+ <table cellspacing="4" cellpadding="0" border="0">
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#ffffff"><pre>
+<?xml version="1.0" encoding="UTF-8" ?>
+<log4j:configuration debug="true"
xmlns:log4j='http://jakarta.apache.org/log4j/'>
+
+ <root>
+ <level value ="info" />
+ <appender-ref ref="jetspeed" />
+ </root>
+
+ <logger name="org.apache.jetspeed"
additivity="false">
+ <priority value="debug"/>
+ <appender-ref ref="jetspeed"/>
+ </logger>
+
+ <logger name="org.apache.jetspeed.services"
additivity="false">
+ <priority value="debug"/>
+ <appender-ref ref="jetspeedsrv"/>
+ </logger>
+
+ <logger
name="org.apache.jetspeed.services.psmlmanager.CastorPsmlManagerService"
additivity="false">
+ <priority value="info"/>
+ <appender-ref ref="jetspeedsrv"/>
+ </logger>
+
+ <logger
name="org.apache.jetspeed.services.logging.JetspeedLoggingService"
additivity="false">
+ <priority value="info"/>
+ <appender-ref ref="turbine"/>
+ </logger>
+
+ <logger
name="org.apache.jetspeed.services.portletstats.JetspeedPortletStatsService."
additivity="false">
+ <priority value="info"/>
+ <appender-ref ref="access"/>
+ </logger>
+
+ <appender name="jetspeed"
class="org.apache.log4j.FileAppender">
+ <param name="File"
value="${webappRoot}/WEB-INF/log/jetspeedX.log" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d [%t] %-5p %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="jetspeedsrv"
class="org.apache.log4j.FileAppender">
+ <param name="File"
value="${webappRoot}/WEB-INF/log/jetspeedservicesX.log" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d [%t] %-5p %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="turbine"
class="org.apache.log4j.FileAppender">
+ <param name="File"
value="${webappRoot}/WEB-INF/log/turbineX.log" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d [%t] %-5p %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="access"
class="org.apache.log4j.FileAppender">
+ <param name="File"
value="${webappRoot}/WEB-INF/log/access.log" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d [%t] %-5p %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+</log4j:configuration>
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
1.2 +25 -0
jakarta-jetspeed/src/java/org/apache/jetspeed/services/logging/JetspeedLogFactoryService.java
Index: JetspeedLogFactoryService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/logging/JetspeedLogFactoryService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JetspeedLogFactoryService.java 23 Jul 2003 20:24:25 -0000 1.1
+++ JetspeedLogFactoryService.java 26 Jul 2003 04:36:58 -0000 1.2
@@ -95,6 +95,11 @@
private static final String CONFIG_LOG4J_WATCHINTERVAL = "log4j.watchInterval";
private static final long CONFIG_LOG4J_WATCHINTERVAL_DEFAULT = 60000L;
private ServletContext context;
+ /**
+ * Flag to check for initilization. Needed to make time of init more robust.
+ * Also, cannot access the init in parent class from static method
+ */
+ private static boolean initDone = false;
/**
* Default constructor
@@ -168,6 +173,7 @@
}
}
setInit(true);
+ initDone = true;
} // init
/**
@@ -176,6 +182,25 @@
*/
public static JetspeedLogger getLogger(String loggerName)
{
+ // This test needed to ensure correct init sequence between this and
services that log.
+ if (!initDone)
+ {
+ synchronized (JetspeedLogFactoryService.class)
+ {
+ if (!initDone)
+ {
+ try
+ {
+ new JetspeedLogFactoryService().init();
+ }
+ catch(Exception e)
+ {
+ System.err.println("Init failed no logging available" +
e.getMessage());
+ e.printStackTrace();
+ }
+ }
+ }
+ }
Logger newLog = LogManager.getLogger(loggerName);
JetspeedLogger newLogger = new JetspeedLogger(newLog);
return newLogger;
1.5 +5 -3 jakarta-jetspeed/webapp/WEB-INF/conf/log4j.properties
Index: log4j.properties
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/log4j.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- log4j.properties 24 Jul 2003 00:17:38 -0000 1.4
+++ log4j.properties 26 Jul 2003 04:36:58 -0000 1.5
@@ -19,10 +19,12 @@
#
# If we don't know the logging facility, put it into the
-# jetspeed.log. Add "stdout" to the list for console logging.
+# jetspeed.log. Add "stdout" to each logger that you want
+# to 'echo' its messages to the system console:
+# for example: log4j.category.org.apache.jetspeed = DEBUG, jetspeed, stdout
#
log4j.rootLogger = INFO, jetspeed
-log4j.debug = true
+log4j.debug = false
#
# Jetspeed goes into Jetspeed Log
#
1.1 jakarta-jetspeed/webapp/WEB-INF/conf/log4j.xml
Index: log4j.xml
===================================================================
<?xml version="1.0" encoding="UTF-8" ?>
<log4j:configuration debug="true" xmlns:log4j='http://jakarta.apache.org/log4j/'>
<root>
<level value ="info" />
<appender-ref ref="jetspeed" />
</root>
<logger name="org.apache.jetspeed" additivity="false">
<priority value="debug"/>
<appender-ref ref="jetspeed"/>
</logger>
<logger name="org.apache.jetspeed.services" additivity="false">
<priority value="debug"/>
<appender-ref ref="jetspeedsrv"/>
</logger>
<logger
name="org.apache.jetspeed.services.psmlmanager.CastorPsmlManagerService"
additivity="false">
<priority value="info"/>
<appender-ref ref="jetspeedsrv"/>
</logger>
<logger name="org.apache.jetspeed.services.logging.JetspeedLoggingService"
additivity="false">
<priority value="info"/>
<appender-ref ref="turbine"/>
</logger>
<logger
name="org.apache.jetspeed.services.portletstats.JetspeedPortletStatsService."
additivity="false">
<priority value="info"/>
<appender-ref ref="access"/>
</logger>
<appender name="jetspeed" class="org.apache.log4j.FileAppender">
<param name="File" value="${webappRoot}/WEB-INF/log/jetspeedX.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d [%t] %-5p %c{1} - %m%n"/>
</layout>
</appender>
<appender name="jetspeedsrv" class="org.apache.log4j.FileAppender">
<param name="File"
value="${webappRoot}/WEB-INF/log/jetspeedservicesX.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d [%t] %-5p %c{1} - %m%n"/>
</layout>
</appender>
<appender name="turbine" class="org.apache.log4j.FileAppender">
<param name="File" value="${webappRoot}/WEB-INF/log/turbineX.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d [%t] %-5p %c{1} - %m%n"/>
</layout>
</appender>
<appender name="access" class="org.apache.log4j.FileAppender">
<param name="File" value="${webappRoot}/WEB-INF/log/access.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d [%t] %-5p %c{1} - %m%n"/>
</layout>
</appender>
</log4j:configuration>
1.11 +54 -11 jakarta-jetspeed/xdocs/code-standards.xml
Index: code-standards.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/xdocs/code-standards.xml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- code-standards.xml 16 May 2003 22:25:14 -0000 1.10
+++ code-standards.xml 26 Jul 2003 04:36:58 -0000 1.11
@@ -316,24 +316,67 @@
<section name="Logging">
<p>
- In general logging should be kept to a minimum. Logging is very usefully
- for diagnosing and resolving problems. Error message should describe the
+ Logging is very useful for diagnosing and resolving problems. As a general
rule, all exceptions should be logged,
+ and done so in the following fashion: <br/>
+ <code>logger.error("What went wrong", ex);</code> <br/>
+ This way, both your message and a stack trace of the exception will be
logged. Your error message should describe the
error, and where practical the cause and suggested solutions.
+ Do not log exceptions like this: <code>logger.error(ex);</code> Whenever you
want to log a Throwable, it should be the
+ second parameter of your fatal/error/warn/info/debug call.
+ </p>
+ <p>
+ Since the new logging scheme uses Log4J, the penalty of log statements that
are not actually activated, such as debug,
+ is negligable. However, if your log message uses String concatenation ("+"),
avoid loads of objects to be garbage collected by always
+ checking if the particular level you are logging is enabled, by calling eg.
<code>logger.isDebugEnabled()</code>.
+ This is not necessary for logging simple Strings. Also, if you are building
your message by concatenation, use
+ StringBuffer and .append() instead of String and "+". Your code will be more
efficient and produce less garbage.
</p>
<p>
Debug logging is intended for development and problem determination. It
- is not intended for use in a "normal" production environment. In part
- because of the resource, including CPU and disk space, required. So use
- <code>Log.getLogger().isDebugEnabled()</code> to determine if debug
- logging is enable before generating the debug message.
+ is not intended for use in a "normal" production environment. Therefore do
not depend on important
+ information to be logged using debug. Do, however, add a reasonable about of
debug logging in your code, expecially where
+ robustness checks fail and "strange" things happen. This makes bug hunting a
lot easier! <br/>
+ Do NOT use levels above debug, such as info, for debug messages!
+ </p>
+<source><![CDATA[
+if (logger.isDebugEnabled())
+{
+ StringBuffer msg = New StringBuffer("accessing rundata ");
+ mgs.append(m_runDataStore.get(Thread.currentThread());
+ msg.append(" for thread: ");
+ msg.append(Thread.currentThread());
+ logger.debug(msg.toString());
+}
+]]></source>
+ <p>
+ The following code snippet shows how to use the new logging features.
</p>
<source><![CDATA[
-if (Log.getLogger().isDebugEnabled())
+package mypackage;
+// The two imports needed
+import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
+import org.apache.jetspeed.services.logging.JetspeedLogger;
+
+class MyClass
{
- Log.debug("JetspeedRunDataService: accessing rundata "
- + m_runDataStore.get(Thread.currentThread())
- + " for thread: " + Thread.currentThread());
+ /**
+ * Static initialization of the logger for this class
+ */
+ private static final JetspeedLogger logger =
JetspeedLogFactoryService.getLogger(MyClass.class.getName());
+
+ /**
+ * Some method
+ */
+ someMethod()
+ {
+
+ ...
+ logger.debug("This message should be logged");
+
+ }
+
}
+
]]></source>
</section>
1.18 +209 -323 jakarta-jetspeed/xdocs/config_guide.xml
Index: config_guide.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/xdocs/config_guide.xml,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- config_guide.xml 1 Jul 2003 15:09:04 -0000 1.17
+++ config_guide.xml 26 Jul 2003 04:36:58 -0000 1.18
@@ -238,226 +238,40 @@
</section>
<section name="Set Jetspeed logging">
<p>
- Jetspeed utilizes the logging services provided by Turbine. The logfile(s)
are
+ As og 1.4b5, Jetspeed Log4J for logging. The logfile(s) are
a valuable tool in trouble shooting problems and monitoring the general
health of
Jetspeed an it's portlets.
</p>
<p>
+ The base configuration of the logging is set in the settings in
JetspeedResources.properties shown below.
+ The details of the configuration is done in the file specified by
log4j.properties.
+ The way Jetspeed logs, you are able to controlled logging very detailed, if
you should need so.
+ Jetspeed defines a named logger for every single class that performs
logging. Thus, you can configure it so
+ that a single class logs debug to its own file. This level of detail gives
you better control when debugging!
+ The configuration shipped with Jetspeed is set up on a much coarser level
initially.</p>
+<source>
+#########################################
+# JetspeedLogFactory Service #
+#########################################
+# If this file has extension properties, then log4j property configuration is done.
+# Otherwise DOM configuration for XML. Thus you can choose what format you like to
use.
+log4j.properties=/WEB-INF/conf/log4j.properties
+# If true, Log4J will monitor the property file and reconfigure if changed.
+log4j.configureAndWatch=true
+# Number of ms between each property file check
+log4j.watchInterval=60000
+</source>
+ <!--/p-->
+ <p>
The logging level should be set according the the current needs. DEBUG
logging is
suggested during portlet testing, while INFO logging is appropriate for
every-day
- activity in a stable environment.
+ activity in a stable environment. In heavy production systems, WARN is
appropriate.
</p>
<p>
- Not all of Turbine's logging services are included. Additional
documentation can
- be found at <a
href="http://jakarta.apache.org/turbine">http://jakarta.apache.org/turbine</a>.
+ Detailed information on Log4J canbe found at
+ <a
href="http://jakarta.apache.org/log4j">http://jakarta.apache.org/log4j</a>.
</p>
- <table>
- <tr>
- <th>Facility</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>rotation</td>
- <td>
- Rotation of log files. This will limit the amount of disk space
- consumed by the log file. Not supported by all loggers. To enable this
- logger, you must replace "logforj" with "rotation" on the facilities
list
- and set default logger to "rotation". Please check log4j documentation
- for information on various appenders that can be used here (i.e.
- RollingFileAppender vs. DailyRollingFileAppender).
- </td>
- </tr>
- <tr>
- <td>debug</td>
- <td>
- This logger sends log messages to both console and log file. It is
useful
- for testing and debugging but is not appropriate for production use.
- To enable this logger, you must add "debug" to the facilities list
- and set default logger to "debug".
- </td>
- </tr>
- <tr>
- <td>schedule</td>
- <td>
- A facility for the scheduler service
- To disable started/stopped messages set the level to ERROR
- </td>
- </tr>
- <tr>
- <td>security</td>
- <td>
- A facility for security audit. NOTE! As of 23 Jan 2001
- Turbine does not have any standard security auditing
- functionality. It's up to your application.
- </td>
- </tr>
- <tr>
- <td>system</td>
- <td>A facility for system logging.</td>
- </tr>
- <tr>
- <td>sql</td>
- <td>
- A facility for SQL query logging
- To enable SQL query logging, set the level to DEBUG
- </td>
- </tr>
- </table>
<br/>
- <subsection name="FileLogger">
- <p>
- This is a logging service provide with Turbine.
- </p>
- <p>
- Additional information can be found at <a
href="http://jakarta.apache.org/turbine">
- http://jakarta.apache.org/turbine</a>
- </p>
- <table>
- <tr>
- <th>Facility</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>destination.file</td>
- <td>Name of the log file relative to <jetspeed-home></td>
- </tr>
- <tr>
- <td>className</td>
- <td>org.apache.turbine.services.logging.FileLogger</td>
- </tr>
- <tr>
- <td>level</td>
- <td>
- <table>
- <tr>
- <th>Value</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>ERROR</td>
- <td>Designates error events that might still allow the
application to continue running</td>
- </tr>
- <tr>
- <td>WARN</td>
- <td>Designates potentially harmful situations</td>
- </tr>
- <tr>
- <td>INFO</td>
- <td>Designates informational messages that highlight the progress
of the application at course-grained level.</td>
- </tr>
- <tr>
- <td>DEBUG</td>
- <td>Designates fine-grained informational events that are most
useful to debug an application</td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>destination.console</td>
- <td>Optional, default = false <br/>
- <table>
- <tr>
- <th>Value</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>false</td>
- <td>message will NOT be sent to the console</td>
- </tr>
- <tr>
- <td>true</td>
- <td>message will ALSO be sent to the console</td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td></td>
- <td></td>
- </tr>
- </table>
- </subsection>
- <subsection name="Log4JavaLoggger">
- <p>
- This is a more functional logging service that can interact with
operating specific
- facilities like UNIX's syslog and Window's Event Logger
- </p>
- <p>
- Additional information can be found at <a
href="http://jakarta.apache.org/log4j">
- http://jakarta.apache.org/log4j</a> and <a
href="http://jakarta.apache.org/turbine">
- http://jakarta.apache.org/turbine</a>
- </p>
- <p>
- Configuration notes:
- <ul>
- <li>
- All loggers define in <tt>services.LoggingService.facilities</tt>
must
- be the same type when using the Log4J services.
- </li>
- <li>
- When using log file rotation, the rotation facility must be the first
in the
- <tt>services.LoggingService.facilities</tt> list and should replace
the logforj
- facility.
- </li>
- </ul>
- </p>
- <table>
- <tr>
- <th>Facility</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>destination.file</td>
- <td>Name of the log file relative to <jetspeed-home></td>
- </tr>
- <tr>
- <td>className</td>
- <td>org.apache.turbine.services.logging.Log4JavaLogger</td>
- </tr>
- <tr>
- <td>level</td>
- <td>
- <table>
- <tr>
- <th>Value</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>FATAL</td>
- <td>Designates very severe error events that will presumably lead
the application to abort.</td>
- </tr>
- <tr>
- <td>ERROR</td>
- <td>Designates error events that might still allow the
application to continue running</td>
- </tr>
- <tr>
- <td>WARN</td>
- <td>Designates potentially harmful situations</td>
- </tr>
- <tr>
- <td>INFO</td>
- <td>Designates informational messages that highlight the progress
of the application at coarse-grained level.</td>
- </tr>
- <tr>
- <td>DEBUG</td>
- <td>Designates fine-grained informational events that are most
useful to debug an application</td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>MaxFileSize</td>
- <td>Approximate log file size in bytes. 1MB = 1048576 bytes</td>
- </tr>
- <tr>
- <td>MaxBackupIndex</td>
- <td>
- Number of backup log files to maintain. The actual number of log
files
- will be file.backups + 1.
- </td>
- </tr>
- </table>
- </subsection>
<subsection name="Portlet usage logger">
<p>
This facility is useful to generate web server like access log which
@@ -476,10 +290,6 @@
<td>Simple implementation using Apache Common Log Format (CLF)</td>
</tr>
<tr>
- <td>services.PortletStats.logger = access</td>
- <td>Name of the log4j logger</td>
- </tr>
- <tr>
<td>services.PortletStats.enabled = false</td>
<td>This service is disabled by default</td>
</tr>
@@ -492,127 +302,203 @@
<td>Date format to use in the log entry</td>
</tr>
</table>
+ <p>
+ NOTE: In addition, the category/logger named
"org.apache.jetspeed.services.portletstats.JetspeedPortletStatsService"
+ in the Log4J configuration controls where the actual logging goes. This
must be set to log at level INFO for
+ the portlet usage logger to be active.
+ </p>
</subsection>
<subsection name="Example configuration">
<p>
- The following configuration will rotate the logging among 6 files. All
logging
- will be at the DEBUG level.
+ The following configuration will log all general Jetspeed log to one
file, all Jetspeed services to one, and all
+ logging from turbine to a third. In addition, the neccesary logger for
the portlet usage is defined.<br/>
+ NOTE: If you remove the "{1}" behind the %c in the patterns in the
configuration, you will get tha fully
+ qualified class name (i.e. including package name) in the log file. This
might be useful.
</p>
<source>
# -------------------------------------------------------------------
+#
+# This file contains log4j-specifc logging properties. This file is
+# loaded by the logging service based on the following property
+# in JetspeedResources.properties:
#
-# L O G S
+# log4j.properties = ${webappRoot}/WEB-INF/conf/log4j.properties
#
-# -------------------------------------------------------------------
-# This is the configuration for the logging system. In most cases
-# you don't need to modify anything. However, if you wish to add more
-# facilities or modify the existing settings, then you can do so.
+# Appender specified in log4j.category.default must be the same as
+# the one specified in services.LoggingService.default property.
+#
+# All log4j properties should be supported. Check log4j documentation
+# for more information.
+#
+# Note that strings containing "," (comma) characters must backslash
+# escape the comma (i.e. '\,')
#
-# destination.file: A path relative to the web app root
# -------------------------------------------------------------------
-services.LoggingService.facilities=logforj,access
-services.LoggingService.default=logforj
-services.LoggingService.loggingConfig=org.apache.turbine.services.logging.PropertiesLoggingConfig
-
-# A facility for system logging.
-services.LoggingService.system.destination.file=/WEB-INF/log/jetspeed.log
-services.LoggingService.system.className=org.apache.turbine.services.logging.FileLogger
-services.LoggingService.system.level=DEBUG
-
-# A facility for the scheduler service
-# To disable started/stopped messages set the level to ERROR
-services.LoggingService.scheduler.destination.file=/WEB-INF/log/jetspeed.log
-services.LoggingService.scheduler.className=org.apache.turbine.services.logging.FileLogger
-services.LoggingService.scheduler.level=DEBUG
-
-# A facility for debugging applications. Messages will go both
-# to the log file and the server console.
-services.LoggingService.debug.destination.file=/WEB-INF/log/jetspeed.log
-services.LoggingService.debug.destination.console=true
-services.LoggingService.debug.className=org.apache.turbine.services.logging.FileLogger
-services.LoggingService.debug.level=DEBUG
-
-# A facility for SQL query logging
-# To enable SQL query logging, set the level to DEBUG
-services.LoggingService.sql.destination.file=/WEB-INF/log/jetspeed.log
-services.LoggingService.sql.className=org.apache.turbine.services.logging.FileLogger
-services.LoggingService.sql.level=DEBUG
-
-# A facility for security audit. NOTE! As of 23 Jan 2001
-# Turbine does not have any standard security auditing
-# functionality. It's up to your application.
-services.LoggingService.security.destination.file=/WEB-INF/log/jetspeed.log
-services.LoggingService.security.className=org.apache.turbine.services.logging.FileLogger
-services.LoggingService.security.level=DEBUG
-
-# An example configuration for using Log4Java, with log4j properties inline
-# The category name - at the end of this line - needs to match the logging facility
name - the first log4j.
-# need this rootCategory entry to capture the torque/fulcrum etc logging
-services.LoggingService.logforj.log4j.rootCategory = INFO, logforj
-
-# need this category entry for the actual jetspeed logging (I don't know why it
doesn't get covered by the root category!)
-services.LoggingService.logforj.log4j.category.logforj = DEBUG, logforj
-
-services.LoggingService.logforj.log4j.appender.logforj.file
=${webappRoot}/WEB-INF/log/jetspeed.log
-services.LoggingService.logforj.log4j.appender.logforj =
org.apache.log4j.FileAppender
-services.LoggingService.logforj.log4j.appender.logforj.layout =
org.apache.log4j.PatternLayout
-services.LoggingService.logforj.log4j.appender.logforj.layout.conversionPattern =
[%d{dd MMM yyyy HH:mm:ss} %5p] - %m%n
-services.LoggingService.logforj.log4j.appender.logforj.append = false
-services.LoggingService.logforj.className=org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.logforj.level=DEBUG
-
-# An example configuration for portlet access audit logging
-services.LoggingService.access.log4j.category.access = INFO, access
-services.LoggingService.access.log4j.appender.access = org.apache.log4j.FileAppender
-services.LoggingService.access.log4j.appender.access.layout =
org.apache.log4j.PatternLayout
-services.LoggingService.access.log4j.appender.access.layout.ConversionPattern = %m%n
-services.LoggingService.access.log4j.appender.access.append = true
-services.LoggingService.access.log4j.appender.access.file =
${webappRoot}/WEB-INF/log/access.log
-services.LoggingService.access.className =
org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.access.level = INFO
-
-# An example configuration for automatic log rotation using Log4Java
-# This will keep the log file size under 1MB and save up to 5 backup copies
-services.LoggingService.rotation.log4j.rootCategory = INFO, rotation
-services.LoggingService.rotation.log4j.category.rotation = DEBUG, rotation
-
-services.LoggingService.rotation.log4j.appender.rotation.file =
${webappRoot}/WEB-INF/log/jetspeed.log
-services.LoggingService.rotation.log4j.appender.rotation =
org.apache.log4j.RollingFileAppender
-services.LoggingService.rotation.log4j.appender.rotation.layout =
org.apache.log4j.PatternLayout
-services.LoggingService.rotation.log4j.appender.rotation.layout.conversionPattern =
[%d{dd MMM yyyy HH:mm:ss} %5p] - %m%n
-services.LoggingService.rotation.log4j.appender.rotation.append = false
-services.LoggingService.rotation.log4j.appender.rotation.MaxFileSize = 1024KB
-services.LoggingService.rotation.log4j.appender.rotation.MaxBackupIndex = 5
-services.LoggingService.rotation.className =
org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.rotation.level = DEBUG
-
-# An example configuration for using *NIX syslogd with Log4Java
-services.LoggingService.syslog.destination.syslogd.host=my.syslog.server.com
-services.LoggingService.syslog.destination.syslogd.facility=LOG_DAEMON
-services.LoggingService.syslog.className=org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.syslog.level=INFO
-
-# An example configuration for using remote Log4Java server
-services.LoggingService.remote.destination.remote.host=my.remote.server.com
-services.LoggingService.remote.destination.remote.port=1099
-services.LoggingService.remote.className=org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.remote.level=INFO
-
-# An example configuration for sending error reports as email with Log4Java
-# notes:
-# * uses 'mail.server' as SMTP server to send mail through
-# * log4j will send the email when an ERROR is logged, with
-# 'buffer.size' previous (non-ERROR) logs included in the email
-# * configured to log to a file as well otherwise stacktraces are lost
-services.LoggingService.email.destination.file=/WEB-INF/log/jetspeed.log
[EMAIL PROTECTED]
[EMAIL PROTECTED]
-services.LoggingService.email.destination.email.subject=Jetspeed Error Report
-services.LoggingService.email.destination.email.buffer.size=512
-services.LoggingService.email.className=org.apache.turbine.services.logging.Log4JavaLogger
-services.LoggingService.email.level=INFO
+# The rootlogger means that all logging not defined otherwise, will go where it
describes
+log4j.rootLogger = INFO, jetspeed
+# If debug = true, you will see how Log4J configures on the stdout of your webapp
container
+log4j.debug = true
+#
+# Jetspeed goes into Jetspeed Log
+#
+log4j.category.org.apache.jetspeed = DEBUG, jetspeed
+log4j.additivity.org.apache.jetspeed = false
+
+#
+# Jetspeed services goes into Jetspeed Services Log
+#
+log4j.category.org.apache.jetspeed.services = DEBUG, jetspeedsrv
+log4j.additivity.org.apache.jetspeed.services = false
+# Setting CastorPsmlManagerService to higher level, as it is quite verbose on DEBUG
+log4j.category.org.apache.jetspeed.services.psmlmanager.CastorPsmlManagerService =
INFO, jetspeedsrv
+log4j.additivity.org.apache.jetspeed.services.psmlmanager.CastorPsmlManagerService
= false
+
+#
+# Turbine goes into Turbine Log
+# JetspeedLoggingService handles all logging thru TurbineLoggingService
+#
+log4j.category.org.apache.jetspeed.services.logging.JetspeedLoggingService = INFO,
turbine
+log4j.additivity.org.apache.jetspeed.services.logging.JetspeedLoggingService = false
+
+#
+# Portlet access Category
+#
+log4j.category.org.apache.jetspeed.services.portletstats.JetspeedPortletStatsService
= INFO, access
+log4j.additivity.org.apache.jetspeed.services.portletstats.JetspeedPortletStatsService
= false
+
+#
+# Console output Category
+#
+log4j.category.stdout = INFO, stdout
+log4j.additivity.stdout = false
+
+########################################################################
+#
+# Logfile definitions
+#
+########################################################################
+
+#
+# jetspeed.log
+#
+log4j.appender.jetspeed = org.apache.log4j.FileAppender
+log4j.appender.jetspeed.file = ${webappRoot}/WEB-INF/log/jetspeed.log
+log4j.appender.jetspeed.layout = org.apache.log4j.PatternLayout
+log4j.appender.jetspeed.layout.conversionPattern = %d [%t] %-5p %c{1} - %m%n
+log4j.appender.jetspeed.append = false
+
+log4j.appender.jetspeedsrv = org.apache.log4j.FileAppender
+log4j.appender.jetspeedsrv.file = ${webappRoot}/WEB-INF/log/jetspeedservices.log
+log4j.appender.jetspeedsrv.layout = org.apache.log4j.PatternLayout
+log4j.appender.jetspeedsrv.layout.conversionPattern = %d [%t] %-5p %c{1} - %m%n
+log4j.appender.jetspeedsrv.append = false
+
+#log4j.appender.jetspeed = org.apache.log4j.RollingFileAppender
+#log4j.appender.jetspeed.file = ${webappRoot}/WEB-INF/log/rotation.log
+#log4j.appender.jetspeed.MaxFileSize = 50KB
+#log4j.appender.jetspeed.MaxBackupIndex = 5
+#log4j.appender.jetspeed.layout = org.apache.log4j.PatternLayout
+#log4j.appender.jetspeed.layout.ConversionPattern = [%d{dd MMM yyyy HH:mm:ss} %5p]
- %m%n
+
+#
+# turbine.log
+#
+log4j.appender.turbine = org.apache.log4j.FileAppender
+log4j.appender.turbine.file = ${webappRoot}/WEB-INF/log/turbine.log
+log4j.appender.turbine.layout = org.apache.log4j.PatternLayout
+log4j.appender.turbine.layout.conversionPattern = %d [%t] %-5p %c{1} - %m%n
+log4j.appender.turbine.append = false
+
+#
+# Portlet access Output
+#
+log4j.appender.access = org.apache.log4j.FileAppender
+log4j.appender.access.file = ${webappRoot}/WEB-INF/log/access.log
+log4j.appender.access.layout = org.apache.log4j.PatternLayout
+log4j.appender.access.layout.conversionPattern = %m%n
+log4j.appender.access.append = true
+
+#
+# Console Output
+#
+log4j.appender.stdout = org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern = [%d{dd MMM yyyy HH:mm:ss} %5p] -
%m%n
</source>
+ <p>
+ The following XML configuration shows a similar configuration in XML
format. You can choose
+ your favorite format.
+ </p>
+<source><![CDATA[
+<?xml version="1.0" encoding="UTF-8" ?>
+<log4j:configuration debug="true" xmlns:log4j='http://jakarta.apache.org/log4j/'>
+
+ <root>
+ <level value ="info" />
+ <appender-ref ref="jetspeed" />
+ </root>
+
+ <logger name="org.apache.jetspeed" additivity="false">
+ <priority value="debug"/>
+ <appender-ref ref="jetspeed"/>
+ </logger>
+
+ <logger name="org.apache.jetspeed.services" additivity="false">
+ <priority value="debug"/>
+ <appender-ref ref="jetspeedsrv"/>
+ </logger>
+
+ <logger
name="org.apache.jetspeed.services.psmlmanager.CastorPsmlManagerService"
additivity="false">
+ <priority value="info"/>
+ <appender-ref ref="jetspeedsrv"/>
+ </logger>
+
+ <logger name="org.apache.jetspeed.services.logging.JetspeedLoggingService"
additivity="false">
+ <priority value="info"/>
+ <appender-ref ref="turbine"/>
+ </logger>
+
+ <logger
name="org.apache.jetspeed.services.portletstats.JetspeedPortletStatsService."
additivity="false">
+ <priority value="info"/>
+ <appender-ref ref="access"/>
+ </logger>
+
+ <appender name="jetspeed" class="org.apache.log4j.FileAppender">
+ <param name="File" value="${webappRoot}/WEB-INF/log/jetspeedX.log" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d [%t] %-5p %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="jetspeedsrv" class="org.apache.log4j.FileAppender">
+ <param name="File"
value="${webappRoot}/WEB-INF/log/jetspeedservicesX.log" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d [%t] %-5p %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="turbine" class="org.apache.log4j.FileAppender">
+ <param name="File" value="${webappRoot}/WEB-INF/log/turbineX.log" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d [%t] %-5p %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="access" class="org.apache.log4j.FileAppender">
+ <param name="File" value="${webappRoot}/WEB-INF/log/access.log" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d [%t] %-5p %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+</log4j:configuration>
+
+]]></source>
</subsection>
</section>
<section name="Enable e-mail confirmation">
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]