July 26, 2015
How to enable/disable Tomcat Access logs (logging of each ColdFusion request)
Comments
(3)
July 26, 2015
How to enable/disable Tomcat Access logs (logging of each ColdFusion request)
(3)

[Originally posted on 7/26/15; updated 7/21/21, to correct a problem of missing slashes, improve some formatting, update Tomcat docs link]

Sometimes, depending on your need, you may want to enable or disable the Tomcat access logs, which track every request to ColdFusion. In CF10, these logs were enabled by default. Since CF11, they are disabled by default. This post shows how to enable them, as well as how to modify the logging.

Enabling/disabling the logs

This can be simply done changing a setting a in <ColdFusion_Home>cfusion/runtime/conf/server.xml file. (If running multiple instances, use instancename instead of cfusion.) Before making changes, save a copy of the file.

At the end of this server.xml file you may find the following commented tag:

<!–
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs” 
              prefix=”localhost_access_log.” suffix=”.txt”
              pattern=”%h %l %u %t &quot;%r&quot; %s %b” resolveHosts=”false”/>
–>

To enable the logging, make a copy of the file, then remove the comments. To disable the logging, instead simply comment out the tag, as above (noting the use of two dashes for an XML rather than a CFML comment).

After making the changes, save the file and restart ColdFusion for the changes to take effect.

Do beware that this feature logs EVERY request made to ColdFusion, and so these logs can grow quite large.

Viewing the access log

When enabled, the logs are stored in <ColdFusion_Home>cfusion/runtime/logs (or instancename instead of cfusion).

Modifying the logging

Note finally that you can modify the logging in two ways, by changing attributes within that valve tag above.

First, you can modify the log filename (via the prefix attribute). Second, you can modify what characteristics about each request is logged, via the pattern attribute.

For more information on these and other attributes, and on Tomcat access logging in general, see:
https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Access_Logging

3 Comments
2021-07-21 09:38:29
2021-07-21 09:38:29

Note this should read:

 

<ColdFusion_Home>/cfusion/runtime/conf/server.xml

or for me

C:/ColdFusion2018/cfusion/runtime/conf/server.xml

Like
()
(1)
>
bretweinraub
's comment
2021-07-21 20:09:15
2021-07-21 20:09:15
>
bretweinraub
's comment

Bret, just to clarify, the problem was just that the slashes were missing, but yep that’s been corrected now, along with some other improvements.

Like
()
2015-07-27 02:37:19
2015-07-27 02:37:19

Why is this text blue ?

Like
()
Add Comment