User SSH access to real-time webserver logs?

deltaB

Verified User
Joined
Mar 28, 2024
Messages
14
Hi,

Is there anyway to get users access to realtime webserver logs via SSH?

As far as i can see the /home/user/domains/domain/logs dir only has the previous days zipped logs in it....

Thanks
 
Right, i think cPanel uses a symlink:

The system also performs the following actions:
  • Adds a link to the /etc/apache2/logs/domlogs/USER directory in the /home/USER/access_logs directory.
  • Adds a symlink to the log data backup file in the user’s /home/USER/logs directory during the archive process.
    • This symlink allows you to access this file while the system archives the file.
    • The symlink’s name reflects the log file’s name, and may contain a .bkup file extension.

Source: https://docs.cpanel.net/knowledge-base/cpanel-product/the-cpanel-log-files/

Is there a way to set something similar up for DirectAdmin?
 
Currently no easy task for the symlink too, because DA store the realtime logs as "/var/log/{SERVICE}/domains/{DOMAIN}.log"

If you want to do the same thing as cPanel, you need to change this logics.
 
I don't think that would be an issue as such, cPanel has the same issue. Even if it was just the httpd(apache) logs, that would be fine, as anything nginx (if in use) reverse proxies, would end up in that log anyway.
 
a cronjob with a shell script which copies the log files over into the user directory, and rewrite the user rights ?
 
Not quite as nice as seeing the actual log... but definitely a work around.

Team DA - any chance we can add this as a feature request?
 
Team DA - any chance we can add this as a feature request?
Yes on the https://feedback.directadmin.com site.

However, they can access the logfiles fairly realtime already via the logs option in DA.
I can see logs in there from up to a few seconds ago and one can choose to also view the complete log. Same for eror logfile.

So in fact that is realtime.

Really realtime like with the tail command is only possible for root. Should also not be required for users so I doubt a request would be created but you can always try.
 
Many thanks, good to know.

The use case is debugging an error or access issue. So for example you might mant to curl a URL and then watch the access request come through, or the error appear.
 
One could reload that page after using that curl command. Then this would be visible too.
Specialistic user is he can do something like that. Those kinds of test are normally done by devs or admins.
 
You can maybe use a "Custom HTTPD Configuration" to tell Apache to write an additional set of logs, for example in the CUSTOM2 section for a domain:

Code:
CustomLog |HOME|/live-logs/|DOMAIN|.log combined

Make sure the directory exists and that the logs can be written there. You probably want to set up some kind of log rotation to avoid them growing forever.

I don't think ErrorLog is allowed to be defined multiple times, but you can try it. If not, there might be some workarounds you can do with piping.
 
Back
Top