The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

vhost.local tempate custom logs

Discussion in 'General Discussion' started by juliovedovatto, Aug 20, 2011.

  1. juliovedovatto

    juliovedovatto Registered

    Joined:
    Aug 20, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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?
     
Loading...

Share This Page