unixmiah
unixmiah

Reputation: 3145

enable mod_rewrite logs in apache running on ubuntu

I tried to enable logging. I enabled mod rewrite and restarted the computer, for some reason the rewrite log doesn't write to the destination directory /var/lib/log

I'm wondering if anyone had done it before successfully, please post it here so I can give it a try.

cat /etc/issue
Ubuntu 16.04.1 LTS \n \l

apache2 -v
Server version: Apache/2.4.18 (Ubuntu)
Server built:   2016-07-14T12:32:26

/var/log/apache2$ ls
access.log        access.log.3.gz  error.log.1      error.log.4.gz
access.log.1      access.log.4.gz  error.log.10.gz  error.log.5.gz
access.log.10.gz  access.log.5.gz  error.log.11.gz  error.log.6.gz
access.log.11.gz  access.log.6.gz  error.log.12.gz  error.log.7.gz
access.log.12.gz  access.log.7.gz  error.log.13.gz  error.log.8.gz
access.log.13.gz  access.log.8.gz  error.log.14.gz  error.log.9.gz
access.log.14.gz  access.log.9.gz  error.log.2.gz   other_vhosts_access.log
access.log.2.gz   error.log        error.log.3.gz

<VirtualHost *:80>
    ServerName odyss{shadow}.odysseysafaris.com
    ServerAdmin 
    DocumentRoot /var/www/html/{shadow}
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory "/var/www/html/{shadow}">
        Options FollowSymLinks
        AllowOverride All
    Order allow,deny
        Allow from all

    </Directory>

</VirtualHost>

Upvotes: 1

Views: 1742

Answers (1)

user2493235
user2493235

Reputation:

Apache doesn't have its own log for mod_rewrite in 2.4. It logs to the error log. See Apache Module mod_rewrite - Logging for full details.

The last section is of particular relevance:

RewriteLog

Those familiar with earlier versions of mod_rewrite will no doubt be looking for the RewriteLog and RewriteLogLevel directives. This functionality has been completely replaced by the new per-module logging configuration mentioned above.

To get just the mod_rewrite-specific log messages, pipe the log file through grep:

tail -f error_log|fgrep '[rewrite:'

Also you don't appear to have added any directives to activate the logging. Add something like:

LogLevel rewrite:trace1

Which would just change the mod_rewrite logging and not affect any other. See the above link for more info and see LogLevel:

Specifying a level with a module name will set the level for that module only.

Upvotes: 3

Related Questions