PERL, vlogger log rotation error, rewriting function help

Discussion in 'Server Operation' started by Tomislav Aurednik, Jun 23, 2017.

  1. I really need help from someone who knows perl and linux. I needed to make some adjustments to ISPConfig scripts to get it working with the technologies on my server. Needed to change the website log location from /var/log/ispconfig/httpd/website_name/ (at least I think this is it on Ubuntu) to /var/www/website_name/log/. Before the location was a normal directory but now the website_name is a symlink that shows to clients/clientN/webN/.
    The error or rather entry into the apache2 error.log that I'm getting is:
    "No such file or directory can't open /var/www/website_name/log/20170623-access.log at /usr/local/ispconfig/server/scripts/vlogger line 447, <STDIN> line 2."

    the code on that line is:
    open $vhost, ">>${vhost}" . time2str( $TEMPLATE, time() ) or die ( "can't open $LOGDIR/${vhost}" . time2str( $TEMPLATE, time() ) );
    the $vhost var has the value website_name.tld/log/ and the $LOGDIR is /var/www/. So it points to the right location.
    The vlogger works fine, it writes into logs and rotates them. But my /var/log/apache2/error.log gets filled with error messages.

    So is there a perl programer who can help me to fix the code so it will work, because I never programed in perl and don't really know the syntax or even know at least a little to be able to figure it out myself and I don't have time to learn perl.
  2. Fixed!

    Old line:
    open $vhost, ">>${vhost}" . time2str( $TEMPLATE, time() ) or die ( "can't open $LOGDIR/${vhost}" . time2str( $TEMPLATE, time() ) );

    New line:
    open $vhost, ">>$LOGDIR/${vhost}" . time2str( $TEMPLATE, time() ) or die ( "can't open $LOGDIR/${vhost}" . time2str( $TEMPLATE, time() ) );

    It seems that in the creation of that script, we forgot to add the $LOGDIR, which meant that it always wanted to open a non existant location.
    till likes this.

Share This Page