Customizing the Log Format

You are here:
< Back

Customizing Log Format in OpenLiteSpeed is possible, and something you may wish to do during the troubleshooting process. For example, you may want to use NCSA Combined Log Format and then use the apachetop command for further log analysis. Here’s how.

You can set Log Format to whatever you like, for example:

"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"

Setting Log Format overrides the Log Headers setting.

Log Format should be a string. The syntax is compatible with Apache 2.0’s custom log format. Here are a few examples:

Common Log Format (CLF)

"%h %l %u %t \"%r\" %>s %b"

Common Log Format with Virtual Host

"%v %h %l %u %t \"%r\" %>s %b"

NCSA extended/combined log format

"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" 

Log cookie value of Foobar


Alternatively, you can edit the OpenLiteSpeed /usr/local/lsws/conf/htttpd_config.conf configuration file directly, and add the following logFormat line there, like so:

accesslog $SERVER_ROOT/logs/access.log {
  logFormat               "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"
  rollingSize             10M
  keepDays                30
  compressArchive         0

Restart OpenLiteSpeed when your changes are complete.

Previous How To Set Server Environment Variables
Next Show Real Visitor IP Instead of CloudFlare IPs
Table of Contents