Different Log Files

 
Post new topic   Reply to topic    Aprelium Forum Index -> General Questions
View previous topic :: View next topic  
Author Message
Gerrit
-


Joined: 02 May 2004
Posts: 16

PostPosted: Tue Jul 06, 2004 7:45 am    Post subject: Different Log Files Reply with quote

Hello,

I have the 1.222 and the beta 2 running on two different machines. I 'm using the script for virtual hosting 4 sites. I was wondering if it is possible to have different log files. For each of the virtual hosts, as in Apache. See example from the Apache webserver config file. Awstats can produce a more accurate statistic of the website in this way.

Code:

#<VirtualHost *>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>


Gerrit
Back to top View user's profile Send private message
aprelium-beta
-


Joined: 24 Jun 2004
Posts: 383

PostPosted: Tue Jul 06, 2004 2:18 pm    Post subject: Re: Different Log Files Reply with quote

Gerrit,

The versions you're using are monosite web server (they aren't made to support virtual hosts by default) so this feature is not enabled.
But the multiple-hosting release of version 2 (not yet available for testing) can do this.
_________________
Beta Testing Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Gerrit
-


Joined: 02 May 2004
Posts: 16

PostPosted: Tue Jul 06, 2004 4:56 pm    Post subject: Different log files Reply with quote

I think this is great news.

Quote:

But the multiple-hosting release of version 2 (not yet available for testing) can do this.


I have the beta 2 working on localhost, with perl, php4 and php5 tested, asp, mysql, awstats and so far i have no complaints, everything works fine.
Waiting for the next release.
Thanks for the answer.

Regards,

Gerrit
Back to top View user's profile Send private message
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Tue Jul 06, 2004 10:58 pm    Post subject: Reply with quote

If you have the sites organised into folders, for example

/site1/
/site2/
/site3/

etc, you could extract the information from the existing log file into 3 separate log files easily enough... If you're interested, post a sample line from each separate site, or just your folder names/how you have your subsites organised...
Back to top View user's profile Send private message
Gerrit
-


Joined: 02 May 2004
Posts: 16

PostPosted: Thu Jul 08, 2004 3:56 pm    Post subject: Different log files Reply with quote

Thats right, I have my sites in htdocs as described

My sites have the following names.

/Windvangers
/EefjeBouweriks
/Bouweriks
/Bouweriks_fotoalbum

The only two log files I have are access.log and error.log

I'm using awstats 6.1 .

Is this enough information?

Thanks,

Gerrit.
Back to top View user's profile Send private message
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Thu Jul 08, 2004 6:14 pm    Post subject: Reply with quote

Cut and paste the following into Notepad, save it as "logsplit.bat" - you will need to include the quotes in the Save As dialogue to force Notepad to save as a .bat instead of a .txt file...

If you've changed the directory you installed Abyss into, change the first line accordingly. This is intended for Windows 2000/XP/2003 - if you have 98/Me you'll need to use the 8.3 filename naming convention for the path.

Code:

cd "C:\program files\Abyss Web Server\log"
find /i "/Windvangers/" access.log > Windvangers.log
find /i "/EefjeBouweriks/" access.log > EefjeBouweriks.log
find /i "/Bouweriks/" access.log > Bouweriks.log
find /i "/Bouweriks_fotoalbum/" access.log > Bouweriks_fotoalbum.log


After running the batch file, you should find you now have 4 new log files in your Abyss log directory, each containing only the access log for 1 section of your site. You can run AWStats against these as normal... I don't run AWStats myself, so I don't know if you need to split the errors log too - does it also analyse that ? If it needs splitting, you can repeat the above code, but change access.log for error.log and change the names of each file after the > to generate seperate error logs.

Hope this helps, let me know if you have any problems. As I don't have your access log I can't check that it's worked, but it works with different names for me :)


Last edited by Anonymoose on Thu Jul 08, 2004 9:40 pm; edited 1 time in total
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Jul 08, 2004 6:27 pm    Post subject: Reply with quote

maybe someone should make a GUI for that batch script , I never
knew about this , im going to try and execute shell commands using
PHP and try and create a GUI for that in the future. Thanks man!


Last edited by TRUSTAbyss on Wed Jul 06, 2005 6:39 pm; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Thu Jul 08, 2004 7:09 pm    Post subject: Reply with quote

I think you should be able to do it directly in PHP if you hit on the right commands, it's an ideal language for doing something like this, second only to Perl... Should be better than using shell commands as it'd be platform independent. It would also be very simple to rewrite in VB with a GUI on it, although probably slower than PHP/Perl/DOS.
Back to top View user's profile Send private message
Gerrit
-


Joined: 02 May 2004
Posts: 16

PostPosted: Thu Jul 08, 2004 7:24 pm    Post subject: different log files Reply with quote

Thanks Anonymoose,

The batch file worked fine for one exception. I had to use the real www name instead of the dir. Maybe someone can fit this in a visual basic, delphi program or even a PHP script. Sometime the answer is simple, but I never expected this simple.

Thanks again,

Gerrit.
Back to top View user's profile Send private message
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Thu Jul 08, 2004 7:58 pm    Post subject: Reply with quote

As my site is really only for my own use when I'm not at my PC, I don't really have an access log with enough data in to test on. If anyone would care to donate one, I'll certainly have a crack at it :)
Back to top View user's profile Send private message
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Thu Jul 08, 2004 9:40 pm    Post subject: Reply with quote

Sorry, a silly omission on my part, you should add /i after the find command to make the search case insensitive - see my edited code above. PHP version of the above script should be done shortly, just getting to grips with the ereg command. TRUSTpunk should be able to adapt the form that he made to generate the PHP virtual host scripts to generate my code with any site names / number of site names once it's done :D
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Jul 08, 2004 9:52 pm    Post subject: Reply with quote

Yeah thats no problem , the problem would be to creating a GUI
to execute the batch file to create the logs with a html form. :)
Back to top View user's profile Send private message Visit poster's website
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Thu Jul 08, 2004 10:11 pm    Post subject: Reply with quote

You won't need a GUI to run a batch file - I'm writing it in PHP :D What I'm writing is similar to the virtual hosts script before editing, so I was suggesting in the same way you wrote your "How many sites do you want to create" etc type page, you can have "How many logs do you want to split" then use basically the same form as for Virtual Host creator to allow people to put in their site names + path to the log directory, and generate the PHP for them to download to their machine and run from localhost on their server...

I'm actually running it directly from the php.exe at the moment and it seems to be working fine, just got to finish off the writing out to logs part and I'll post it here for you to tweak.
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Jul 08, 2004 11:27 pm    Post subject: Reply with quote

Ok , I was thinking of actually creating a form where you put the log
splitting settings and when a user finishes , they have the option to
execute the batch file to split the logs remotely using a html form.
Back to top View user's profile Send private message Visit poster's website
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Fri Jul 09, 2004 12:25 am    Post subject: Reply with quote

Ok, there might be some bits here others could improve, this is the first time I've written anything in PHP. On the upside, it definitely works, I've just checked the line counts on the output from this and from my original batch file and they are the same.

The hardcoded paths and site names could be changed to accept a variable inputted in a HTML form. To make it easier on myself I moved the access.log file to my root directory, but changing that path manually is trivial.

Any takers for putting the front end together to generate more general code using variables instead of hardcoded names? I'd be interested in seeing TRUSTpunks code to output PHP code put to good use here...

Code:
<?php
 $logtosplit = fopen("C://access.log", "r");
 $log1= fopen("C://log1.log", "w");
 $log2= fopen("C://log2.log", "w");
 $log3= fopen("C://log3.log", "w");
 $log4= fopen("C://log4.log", "w");

 $site1=strtolower("Windvangers");
 $site2=strtolower("EefjeBouweriks");
 $site3=strtolower("Bouweriks");
 $site4=strtolower("Bouweriks_fotoalbum");

 $unclassified = 0;
 $totallines = 0;
 
    if ($logtosplit) {
     while (!feof($logtosplit)) {
         $linetocheck = fgets($logtosplit);
         $lowercaselinetocheck = strtolower($linetocheck);
         
// The space before the \/ below is deliberate, intended to make it more likely to catch only the beginnings of lines.
//  The \/ at the end is important to ensure it catches only the lines with the exact directory name in and not any other lines which may contain substrings.

         if (ereg(" \/$site1\/", $lowercaselinetocheck)) {fputs($log1, "$linetocheck");}
       elseif (ereg(" \/$site2\/", $lowercaselinetocheck)) {fputs($log2, "$linetocheck");}
       elseif (ereg(" \/$site3\/", $lowercaselinetocheck)) {fputs($log3, "$linetocheck");}
       elseif (ereg(" \/$site4\/", $lowercaselinetocheck)) {fputs($log4, "$linetocheck");}       
         else $unclassified=$unclassified +1;
       $totallines=$totallines+1;
         }
 fclose($pointer);
   }
   
 fclose($log1);
 fclose($log2);
 fclose($log3);
 fclose($log4);

 echo "Splitting Finished.  $totallines-1 lines examined.  $unclassified lines were unclassified.";
 
?>


Note that it is raw PHP - I've been running it against PHP.exe rather than through Abyss, it probably needs tidying up to output anything properly to a webpage after splitting, but the skeleton is there for those who'd like to improve it. Feel free to use it, hack it, change it however you want but credit for the original code would be polite.
Back to top View user's profile Send private message
Gerrit
-


Joined: 02 May 2004
Posts: 16

PostPosted: Mon Jul 12, 2004 8:54 pm    Post subject: Reply with quote

I have a minor update to the file. For people who want the file for there own site it is now easier to adjust.

I'm not good at all in php. Maybe someone can make a for next loop to close the file(s) at the end.
See the code.

Anonymoose, thanks Man,

Code:

<?php
/**************************************************************************
 *                                                                        *
 *    LogSplit - A web analyzer splitter for Awstats and Abyss Web Server *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: logsplit                                             *
 *        Copyright: (C) 2004 Anonymoose                                  *
 *            Email:                                                      *
 *              Web: http://www.Aprelium.com/forum                        *
 *    Scriptversion: 1.0.2                                                *
 *                                                                        *
 *    Never released without support from: Anonymoose                     *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Minor update made by Gerrit Bouweriks                               *
 *                                                                        *
 *************************************************************************/

// Put your Log dir here...
$logdir = "C://WWW//Abyss Web Server//log//";

// The name of your log file
$logfile = "access.log";


$logging = $logdir . $logfile;
$logtosplit = fopen($logging, "r") or die ("Can't open file $logging");

print  "Opening " . $logging . "<br />" ;

// Put your dirs here
$site1=strtolower("Windvangers");
$site2=strtolower("EefjeBouweriks");
$site3=strtolower("Bouweriks");
$site4=strtolower("Bouweriks_fotoalbum");

$log1 = fopen($logdir . $site1 . ".log" , "w");
$log2 = fopen($logdir . $site2 . ".log" , "w");
$log3 = fopen($logdir . $site3 . ".log" , "w");
$log4 = fopen($logdir . $site4 . ".log" , "w");


$unclassified = 0;
$totallines = 0;

    if ($logtosplit) {
     while (!feof($logtosplit)) {
         $linetocheck = fgets($logtosplit);
         $lowercaselinetocheck = strtolower($linetocheck);

// The space before the \/ below is deliberate, intended to make it more likely to catch only the beginnings of lines.
//  The \/ at the end is important to ensure it catches only the lines with the exact directory name in and not any other lines which may contain substrings.

         if (ereg(" \/$site1\/", $lowercaselinetocheck)) {fputs($log1, "$linetocheck");}
       elseif (ereg(" \/$site2\/", $lowercaselinetocheck)) {fputs($log2, "$linetocheck");}
       elseif (ereg(" \/$site3\/", $lowercaselinetocheck)) {fputs($log3, "$linetocheck");}
       elseif (ereg(" \/$site4\/", $lowercaselinetocheck)) {fputs($log4, "$linetocheck");}
        else $unclassified=$unclassified +1;
       $totallines=$totallines+1;
        }
fclose($pointer);
   }
Print "Writing .... <BR /><BR />";

fclose($log1);
fclose($log2);
fclose($log3);
fclose($log4);



echo "Splitting Finished.  $totallines-1 lines examined.  $unclassified lines were unclassified.";

?>
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> General Questions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group