juliovedovatto

Registered
Aug 20, 2011
3
0
51
I trying to create custom logs in my vhost configuration, I read many threads here to find a way to do this by myself.

So, I edited my vhost.local template and add these lines:

Code:
#Check if the directory exists in user account and create custom log file entry
[%- IF file_test('d',vhost.documentroot _ '/../access-logs') %]
[%- log_file_1 = vhost.documentroot _ '/../access-logs/vcommon' -%]
        [%- IF !file_test('f', log_file_1) %]
    #Debug: Trying to created File [%- log_file_1 -%]
                [%- open(FILE_1,'>', \log_file_1) -%]
                [%- close FILE_1 -%]
        [%- END %]
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" vcommon
    CustomLog [% vhost.documentroot %]/access-logs/vcommon vcommon
[%- END %]
When I run "/scripts/rebuildhttpdconf", the output is a error: "Could not process template for apache2: file error - parse error - apache2/vhost.local line 135: unexpected token (FILE_1)".

I tried to use qx/system calling "touch" commeand instead, but not worked. :(

I need to create a empty file if it not exists in the specified folder, I read about open file in perl, but I can't understand where is the error. If I don't create this file, apache fails to restart (Apache needs the file created, the dumbass has not the capacity to create by itself).

Any hint will be appreciated. :D

Best
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Which line is line 135 in that /var/cpanel/templates/apache2/vhost.local file? Is it the one where you are opening the file with [%- open(FILE_1,'>', \log_file_1) -%] code?