Generate Apache logs in different files

1

I have a VM running a single PHP project, uniquely hitherto with external access released. Last week I had to create a folder inside the www with the signatures of the emails of the employees, and the log file at that moment is full, because in every email received from here it saves in the Apache log:

Isthereanywayto"split" the Apache log, one for each project in the WWW folder? Or even disable logging for the "Subscriptions" project?

Update: Apache Version

    
asked by anonymous 29.08.2016 / 19:20

1 answer

0

In the bin of Apache folder there is rotatelogs

This program is useful for generating rotating logs.

Apache rotatelogs

Here is an example of how to generate 1 log file per day:

<IfModule log_config_module>
    LogFormat "%h %l %u %{%Y-%m-%d %H:%M:%S}t \"%r\" %>s %b \"%{Referer}i\"" combined
    CustomLog "|bin/rotatelogs.exe C:/www/site/logs/access/log_access-%Y-%m-%d.txt 86400 +000" combined env=!dontlog
</IfModule>

Comments:
1. Even under Windows environment, the path should use normal bar.
2. The rotatelogs path must be relative, in Windows environment, and should start with the | vertical bar.

C:/www/site/...

Do do not backslash:

C:\www\site\...

The logs will be generated according to the format log_access-%Y-%m-%d.txt

log_access-2016-08-29.txt
log_access-2016-08-30.txt
log_access-2016-08-31.txt

Can also restrict by file size. For example, generate a new log file every 1mb. See the options in the documentation: link

If you just want to disable:

#CustomLog "|bin/rotat...

A simple sharp (#) deactivates the line.





About us Note: Normally in a development environment there is not much reason to save access logs using the Apache logging capabilities.

The most interesting thing might be to save error logs. For this it follows the same form. Just apply it to the ErrorLog parameter.

ErrorLog  "|bin/rotatelogs.exe C:/www/site/logs/errors/log_error-%Y-%m-%d.txt 86400 +000"

The same applies to the Linux environment. Just modify the rotatelog path

Windows: |bin/rotatelogs.exe Linux: bin/rotatelogs

For more functionality, I recommend that you organize each project into an independent virtualhost instead of organizing them into a single virtualhost separated by folders.     

29.08.2016 / 20:23