Lines 62-75
Link Here
|
62 |
<ol> |
62 |
<ol> |
63 |
<li>Create a file called log4j.properties with the following content |
63 |
<li>Create a file called log4j.properties with the following content |
64 |
and save it into common/classes. </li> |
64 |
and save it into common/classes. </li> |
65 |
<li>Use the appropriate file path convention for your OS. Below is |
65 |
|
66 |
a Window example, which on *nix might be |
|
|
67 |
<code>/var/jakarta-tomcat-5.5.4/logs/tomcat.log</code>.</li> |
68 |
<li> |
69 |
<source> |
66 |
<source> |
70 |
log4j.rootLogger=debug, R <br /> |
67 |
log4j.rootLogger=debug, R <br /> |
71 |
log4j.appender.R=org.apache.log4j.RollingFileAppender <br /> |
68 |
log4j.appender.R=org.apache.log4j.RollingFileAppender <br /> |
72 |
log4j.appender.R.File=d:/jakarta-tomcat-5.5.4/logs/tomcat.log <br /> |
69 |
log4j.appender.R.File=${catalina.home}/logs/tomcat.log <br /> |
73 |
log4j.appender.R.MaxFileSize=10MB <br /> |
70 |
log4j.appender.R.MaxFileSize=10MB <br /> |
74 |
log4j.appender.R.MaxBackupIndex=10 <br /> |
71 |
log4j.appender.R.MaxBackupIndex=10 <br /> |
75 |
log4j.appender.R.layout=org.apache.log4j.PatternLayout <br /> |
72 |
log4j.appender.R.layout=org.apache.log4j.PatternLayout <br /> |
Lines 80-85
Link Here
|
80 |
|
77 |
|
81 |
<li><a href="http://logging.apache.org/log4j">Download Log4J</a> |
78 |
<li><a href="http://logging.apache.org/log4j">Download Log4J</a> |
82 |
(v1.2 or later) and place the log4j jar in $CATALINA_HOME/common/lib.</li> |
79 |
(v1.2 or later) and place the log4j jar in $CATALINA_HOME/common/lib.</li> |
|
|
80 |
<li><a href="http://jakarta.apache.org/site/binindex.cgi#commons-logging"> |
81 |
Download Commons Logging</a> and place the commons-logging.jar |
82 |
(not commons-logging-api.jar) in $CATALINA_HOME/common/lib with |
83 |
the log4j jar.</li> |
83 |
<li>Start Tomcat</li> |
84 |
<li>Start Tomcat</li> |
84 |
</ol> |
85 |
</ol> |
85 |
</p> |
86 |
</p> |
Lines 93-116
Link Here
|
93 |
|
94 |
|
94 |
<p> |
95 |
<p> |
95 |
You can (and should) be more picky about which packages to include |
96 |
You can (and should) be more picky about which packages to include |
96 |
in the logging. For example try substituting the |
97 |
in the logging. Tomcat 5.5 uses a new way of restricting logs by Engine |
97 |
last line of the above configuration with one of these: |
98 |
name and Host. For example, for a default Catalina localhost log, add this to the |
98 |
|
99 |
end of the log4j.properties above. Note that there are known issues with |
|
|
100 |
using this naming convention (with square brackets) in log4j XML based |
101 |
configuration files, so we recommend you use a properties file as described |
102 |
until a future version of log4j allows this convention. |
99 |
<ul> |
103 |
<ul> |
100 |
<li>log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG, R</li> |
104 |
<li>log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG, R</li> |
101 |
<li>log4j.logger.org.apache.catalina.core=DEBUG, R</li> |
|
|
102 |
<li>log4j.logger.org.apache.catalina.session=DEBUG, R</li> |
103 |
</ul> |
105 |
</ul> |
|
|
106 |
Be warned a level of DEBUG will produce megabytes of logging and slow startup |
107 |
of Tomcat. This level should be used sparingly when debugging of internal Tomcat |
108 |
operations is required. |
104 |
</p> |
109 |
</p> |
105 |
|
110 |
|
106 |
<p> |
111 |
<p> |
107 |
Your web applications should certainly use their own log4j configuration. |
112 |
In addition, your web applications should use their own log4j configuration. |
108 |
This is valid <i>with</i> the above. You would place a similar log4j.properties |
113 |
This is valid <i>with</i> the above configuration. You would place a similar log4j.properties |
109 |
file in your web application's WEB-INF/classes folder, and log4j1.2.8.jar into |
114 |
file in your web application's WEB-INF/classes folder, and log4j1.2.8.jar into |
110 |
WEB-INF/lib. Then specify your package level logging. This is a basic setup of log4j |
115 |
WEB-INF/lib (commons-logging is not required in this instance). |
|
|
116 |
Then specify your package level logging. This is a basic setup of log4j |
111 |
and you should consult the |
117 |
and you should consult the |
112 |
<a href="http://logging.apache.org/log4j/docs/documentation.html">log4j documentation</a> |
118 |
<a href="http://logging.apache.org/log4j/docs/documentation.html">log4j documentation</a> |
113 |
for more options: this page is intended only as a bootstrapping guide. |
119 |
for more options. Note: this page is intended only as a bootstrapping guide. |
114 |
</p> |
120 |
</p> |
115 |
|
121 |
|
116 |
</section> |
122 |
</section> |