...
In the following example, I will be upgrading a Lucee 5 installation on Ubuntu 16.4 LTS. If you're not running this setup, you may need to interpolate these commands a bit, but the general principals will be the same.
Create the log4j.properties file
...
Code Block | ||
---|---|---|
| ||
# set the log level and name the root logger # Available Levels: DEBUG, INFO, WARN, ERROR, FATAL log4j.rootLogger=INFO, ROOT # set the root logger class log4j.appender.ROOT=org.apache.log4j.RollingFileAppender # set the name/location of the log file to rotate log4j.appender.ROOT.File=${catalina.base}/logs/catalina.out # set the max file size before a new file (and backups) are made log4j.appender.ROOT.MaxFileSize=150MB # set how many iterations of the log file to keep before deleting old logs log4j.appender.ROOT.MaxBackupIndex=10 # set log text formatting log4j.appender.ROOT.layout=org.apache.log4j.PatternLayout log4j.appender.ROOT.layout.ConversionPattern=%p %t %c - %m%n # create a logger for catalina log4j.logger.org.apache.catalina=INFO, ROOT |
Download Log4j
...
Code Block | ||
---|---|---|
| ||
$ cd /opt/lucee/tomcat/lib/ $ sudo wget http://archive.apache.org/dist/logging/log4j/1.2.17/log4j-1.2.17.jar |
Download Tomcat Extras
...
Code Block |
---|
$ cd /opt/lucee/tomcat/lib/ $ sudo wget http://apache.osuosl.org/tomcat/tomcat-8/v8.0.36/bin/extras/tomcat-juli-adapters.jar $ sudo wget http://apache.osuosl.org/tomcat/tomcat-8/v8.0.36/bin/extras/tomcat-juli.jar |
Set the Context Log Attribute
...
Code Block |
---|
<Context useHttpOnly="true" swallowOutput="true"> |
Cleanup and Restart
Last, we need to remove the previous logging.properties file as Tomcat will still read that and create empty log files if we do not remove it. Just delete it or rename it if you want to keep it around for some reason.
Code Block | ||
---|---|---|
| ||
$ cd /opt/lucee/tomcat/conf
$ sudo mv logging.properties logging.properties.bak |
I would also recommend that you clean out the previous logs from the /opt/lucee/tomcat/logs/
directory. To do this, just stop the Lucee service, delete the logs, then start it again. This will make verifying your config much easier, as you can see at a glance if your new logging config has taken effect.
Code Block | ||
---|---|---|
| ||
$ sudo /etc/init.d /lucee_ctl stop
$ sudo rm - rf /opt/lucee/tomcat/logs/*
$ sudo /etc/init.d/lucee_ctl start |
Verify Your Config
Once you've restarted Tomcat. Check your log directory and ensure that the bulk of the log data is now being stored in your catalina.out file. An example resulting log directory can be seen in the image below.
Note that all useful log data is being directed to the catalina.out file.
...