1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Changing the logging of one/all domains

Discussion in 'Plesk 9.x for Linux Issues, Fixes, How-To' started by Loeffel, Aug 2, 2009.

  1. Loeffel

    Loeffel New Pleskian

    19
     
    Joined:
    Aug 2, 2009
    Messages:
    3
    Likes Received:
    0
    Hi,

    I want to anonymize my log files. For this I have a Perl script that replaces the last number of the IP with a zero. That runs fine with every webpage I have manually entered into the apache server. All Plesk build domains just didn't make it correct.

    I have added the errorlog and the customlog into the vhost.conf. The result isn't exactly as expected. He is logging correctly through the perl script as pipe and the last ip triple is zeroed but!!!! he also logs the whole thing again. This time as formatted in the httpd.include. So every access makes two log lines. The correct one and the normal one.

    So how can I disable the logging in the httpd.include or better alter the template, so that I can change it for all domains at once?

    The the lines of the vhost.conf:
    Code:
    CustomLog  "|/srv/execute/aplog-anon /srv/www/vhosts/forum.modellkapitaene.net/statistics/logs/access_log" plesklog
    ErrorLog  "|/srv/execute/aplog-anon /srv/www/vhosts/forum.modellkapitaene.net/statistics/logs/error_log"
    This is the result in the logfile:
    Code:
    10.0.0.116 - - [02/Aug/2009:13:30:15 +0200] "GET /templates/subSilver/images/icon_mini_message.gif HTTP/1.1" 304 - "http://forum.modellkapitaene.net/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
    10.0.0.0 - - [02/Aug/2009:13:30:15 +0200] "GET /templates/subSilver/images/icon_mini_message.gif HTTP/1.1" 304 - "http://forum.modellkapitaene.net/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
    10.0.0.116 - - [02/Aug/2009:13:30:15 +0200] "GET /templates/subSilver/images/icon_mini_login.gif HTTP/1.1" 304 - "http://forum.modellkapitaene.net/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
    10.0.0.0 - - [02/Aug/2009:13:30:15 +0200] "GET /templates/subSilver/images/icon_mini_login.gif HTTP/1.1" 304 - "http://forum.modellkapitaene.net/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
    As you can see, everything is logged twice.
     
  2. riger

    riger Guest

    0
     
    Hi,

    I've found this thread looking for a posibility anonymizing the logs of some domains, hosted on my server (running Plesk 10.1.1).

    Embedding the skript (http://www.zendas.de/technik/sicherheit/apache/scripte.html) via vhost.conf results in logging twice everything.

    There is a second (better a first) CustomLog configuration statement in a generated .conf file in your .../vhosts/[YOUR DOMAIN]/conf directory causing the unwanted first log line with the unshortened IP-adress.

    You can patch the generated file each time you change your configuration or you've to patch (or hack) the file domainVirtualHost.php in your /usr/local/psa/admin/conf/templates/default/domain directory.

    I've replaced the lines:
    Code:
    <?php if (!$VAR->server->webserver->apache->pipelogEnabled): ?>
        CustomLog <?php echo $VAR->domain->physicalHosting->logsDir ?>/<?php echo $OPT['ssl'] ? 'access_ssl_log' : 'access_log' ?> plesklog
    <?php endif; ?>
        ErrorLog  "<?php echo $VAR->domain->physicalHosting->logsDir ?>/error_log"
    
    
    with:
    Code:
    <?php $shortlogconf = $VAR->domain->physicalHosting->vhostDir.'/conf/shortlog'; 
        $shortlogconf.= $OPT['ssl'] ? '_ssl.conf' : '.conf' ; ?>
    
    <?php   if (!file_exists($shortlogconf)): ?>
    <?php if (!$VAR->server->webserver->apache->pipelogEnabled): ?>
        CustomLog <?php echo $VAR->domain->physicalHosting->logsDir ?>/<?php echo $OPT['ssl'] ? 'access_ssl_log' : 'access_log' ?> plesklog
    <?php endif; ?>
        ErrorLog  "<?php echo $VAR->domain->physicalHosting->logsDir ?>/error_log"
    <?php else : ?>
        Include "<?php echo $shortlogconf ; ?>"
    <?php endif; ?>
    
    
    so domainVirtualHost.php (called by /usr/local/psa/admin/bin/httpdmng) looks for the file shortlog.conf / shortlog_ssl.conf in your private conf directory an includes the files (if existing) in your config INSTEAD of the original statements.

    It seems to work fine...
    But be to have backups from all the files you change. In addition: updating plesk will overwrite your patches!
     
Loading...