Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

vhost.local tempate custom logs

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

  1. juliovedovatto

    juliovedovatto Registered

    Aug 20, 2011
    Likes Received:
    Trophy Points:
    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:

    #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

  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Oct 2, 2010
    Likes Received:
    Trophy Points:
    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?
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice