Skip to content

Customize the Log Format

It's possible to customize the log format in OpenLiteSpeed. You may wish to do this when troubleshooting. For example, you may want to use NCSA Combined Log Format and then use the apachetop command for further log analysis.

Formatting

The custom log format should be a string. The syntax is compatible with Apache 2.0's custom log format.

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

"%{Foobar}C"

You can change the log format via the WebAdmin Console, or by editing the OLS configuration file. Either way, restart OpenLiteSpeed when your changes are complete.

Using WebAdmin Console

From the WebAdmin Console, navigate to Server Configuration > Log. Choose a log to edit. We'll edit the Access Log in this example.

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.

Editing the Configuration File

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
}