Skip to end of metadata
Go to start of metadata

The Lucee Installer does not come with ability to rotate logs built into it. Instead, the Lucee installers ship with Tomcat's default logging mechanism, java.util.logging. This is simple and effective logging that will work in most situations, but if you want more complex features, such as rotation based on date or size, you will need to upgrade Tomcat to use a more advanced logging mechanism, such as Log4j.

Thankfully, upgrading to log4j is NOT DIFFICULT. Download a couple things here, tweak a config file there, and you're all set.

The following is intended to be a guide on how to go about downloading and installing log4J on a system that was built using the Lucee Installers.

Review the Tomcat Guide (optional)

Much of the following is just a customized from of the Tomcat documentation, which, if you want to review the original, can be found here.

Installing Log4J Walkthough

The following guide will assume you've installed Lucee to the default location of /opt/lucee, and the directories stated here will be written accordingly. If you installed Lucee to a different location, you will need to update the example directories to match where you installed Lucee.

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 file

Start out by creating a standard config file. This config file will force the majority of relevant logging info to be logged in the catalina.out file. When we're done, other log files will be created, but they should not contain any actual information with the exception of a single line on occasion.

Create a new text file in /opt/lucee/tomcat/lib/ called

$ cd /opt/lucee/tomcat/lib/
$ sudo vim

Then add the following text to it:

# 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
# set the name/location of the log file to rotate
# set the max file size before a new file (and backups) are made
# set how many iterations of the log file to keep before deleting old logs
# set log text formatting
log4j.appender.ROOT.layout.ConversionPattern=%p %t %c - %m%n
# create a logger for catalina, ROOT

Download Log4j

At the time of this writing, log4j 2.0 beta is available, but the Tomcat documentation for log4j (link above) says that Tomcat requires the 1.2.x version, which can be found in the archived versions here:

Copy the log4j-1.2.17.jar file to /opt/lucee/tomcat/libdirectory, and you're done with this step.

$ cd /opt/lucee/tomcat/lib/
$ sudo wget

Download Tomcat Extras

There are two additional JAR's Tomcat will need in order to use Log4j, these are tomcat-juli.jar and tomcat-juli-adapters.jar These are "extras" that the Tomcat project keeps up to date and provides downloads for. You can download these two files from the Tomcat download page, under "Extras":

$ cd /opt/lucee/tomcat/lib/
$ sudo wget
$ sudo wget

Set the Context Log Attribute

We will need to update the default context config so that logging data is "trapped" and placed in the default root logger. In order to do this, we need to edit the default context file in/opt/lucee/tomcat/conf/context.xml.

In that file, we need to update this line:

<Context useHttpOnly="true">

to this:

<Context useHttpOnly="true" swallowOutput="true">

Cleanup and Restart

Last, we need to remove the previous 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.

$ cd /opt/lucee/tomcat/conf
$ sudo mv


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.

$ 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.

If you have any questions, or if you run into any issues, please contact our Support department via email, phone, or web chat.

  • No labels