Split log file

Locked
Vito
Posts: 16
Joined: Sat 29. Sep 2018, 15:06

Split log file

Post by Vito »

Is there any way to have separate log file for each domain?

I mean, I have couple domains and it make very difficult to analyze data :(
User avatar
Tobi
Community Moderator
Posts: 2812
Joined: Thu 5. Jan 2017, 13:24

Re: Split log file

Post by Tobi »

Have a look here:
viewtopic.php?t=1406

This works fine for me.

Hopefully you can read German ;)
Otherwise I would have to translate it to English.

Oh, No, Please Not!
:mrgreen:
Gruß,
Tobi


-----------------------------
wewoco.de
Das Forum für Reseller, Digital-Agenturen, Bildschirmarbeiter und Mäuseschubser
Vito
Posts: 16
Joined: Sat 29. Sep 2018, 15:06

Re: Split log file

Post by Vito »

I wish, but no :mrgreen:

thats why I'm in English section, maybe google translate help me :?
User avatar
Tobi
Community Moderator
Posts: 2812
Joined: Thu 5. Jan 2017, 13:24

Re: Split log file

Post by Tobi »

ask if you don't get it translated.
I'll help you
Gruß,
Tobi


-----------------------------
wewoco.de
Das Forum für Reseller, Digital-Agenturen, Bildschirmarbeiter und Mäuseschubser
Vito
Posts: 16
Joined: Sat 29. Sep 2018, 15:06

Re: Split log file

Post by Vito »

Well, heavy stuff, understand 50%.

If i use this method, what happens with current data in access.log?

also i found tool "goaccess" you can probably use it to view statistics for each domain from a single file. probably...
User avatar
Tobi
Community Moderator
Posts: 2812
Joined: Thu 5. Jan 2017, 13:24

Re: Split log file

Post by Tobi »

Vito wrote: Wed 10. Oct 2018, 16:55 Well, heavy stuff, understand 50%.
If you unterstood the important 50%, that´s enough :lol:
Vito wrote: Wed 10. Oct 2018, 16:55 If i use this method, what happens with current data in access.log?
The current logfiles remain unchanged.
It only changes the behaviour of future logfiles.
After the patch is applied and active it will generate separate logfiles for all your domains.
But only the access logfiles. errorlogs etc. are also unchanged.
Gruß,
Tobi


-----------------------------
wewoco.de
Das Forum für Reseller, Digital-Agenturen, Bildschirmarbeiter und Mäuseschubser
Vito
Posts: 16
Joined: Sat 29. Sep 2018, 15:06

Re: Split log file

Post by Vito »

If think the simplest way to go is one user = one domain :(


Devs
This is really not good idea have one access.log for ALL domains
nobody does that now. at least the last 10 years..
select name from me;
Posts: 579
Joined: Tue 9. Feb 2016, 16:44

Re: Split log file

Post by select name from me; »

Vito wrote: Wed 10. Oct 2018, 12:44 I wish, but no :mrgreen:

thats why I'm in English section, maybe google translate help me :?
Better use this:
https://deepl.com/translator

Just copy the german text in the left textarea field.
Viele Grüße, Christian
User avatar
Tobi
Community Moderator
Posts: 2812
Joined: Thu 5. Jan 2017, 13:24

Re: Split log file

Post by Tobi »

select name from me; wrote: Thu 11. Oct 2018, 10:15 Better use this:
https://deepl.com/translator
My English has never been better :lol:
Gruß,
Tobi


-----------------------------
wewoco.de
Das Forum für Reseller, Digital-Agenturen, Bildschirmarbeiter und Mäuseschubser
select name from me;
Posts: 579
Joined: Tue 9. Feb 2016, 16:44

Re: Split log file

Post by select name from me; »

:lol:
Viele Grüße, Christian
User avatar
Szektor
Posts: 10
Joined: Mon 17. May 2021, 23:35
Location: Budapest
Contact:

Re: Split log file

Post by Szektor »

I used this translator and here is the awesome result:
------------------------------------------------------------------

I have had my own solution for generating domain-specific log files for over a year now.
All you need is a root cronjob, a small adjustment to "/etc/logrotate.d/" and my PHP script.

First open the script locally (best with Notepad++ or another UTF-8 / UNIX compliant editor) and adjust lines 3 to 5 at the beginning of the script.

Code: Select all

$vhost_dir = "/etc/apache2/keyhelp/vhosts";
$backup_dir = "/root/CRONJOBS/vhost_conf_files_backup";
$logfile = "/root/CRONJOBS/vhost_cron_logfile.log";
$vhost_dir ==> path to the Keyhelp V-Hosts files, doesn't really need to be adjusted
$backup_dir ==> the directory must exist. This is where backup files of the original V-Hosts files are stored. No slash at the end!
$logfile ==> the changes are logged in this file. It can also be in the webroot of another user (admin).

Now store the file on the server (in my case /root/CRONJOBS/) and make it executable (chmod 755).
Change the file extension to ".php" and then set up a cronjob as root.
For me, the cronjob runs once an hour.

Next, an adjustment in the log file rotation is necessary.
Details can be found here: viewtopic.php?p=5041#p5041

Well, and that's it.

How does the script work?
=======================
When called, the script first determines when it was last run.
Then it scans the $vhost_dir folder for new or changed V-Host files.
If one is found, the line "CustomLog" is adjusted.
"/home/users/username/access.log" becomes "/home/users/username/domain.tld.access.log".
All subdomains are written to the domain-specific log file.
The "ErrorLog" remains unchanged.
The changed V-Host file is saved and Apache is restarted.
No file locking with "chattr -i" is necessary. Keyhelp also works with the adapted version.

====================================================================
I am always open for ideas, opinions, praise, suggestions, criticism and tips :lol: .
Just report here in the thread. Then you will be helped.

So and now have fun with the domain-specific logfiles.
LINK TO FILE

Greetings,
Tobi
Locked