How can I configure the PHP Notices to only be logged into the error log of the specific VHost?

#1
TL;DR: Main question: How can I configure the PHP Notices to only be logged into the error log of the specific VHost?

I have a VHost with the config below. Error log is set to the location $VH_ROOT/logs/error.log (that is, the root directory of the VHost), yet logs are written at /usr/local/lsws/logs (i.e. $SERVER_ROOT/logs).

/usr/local/lsws/conf/httpd_config.conf:
Code:
virtualhost sub.domain.com {
  vhRoot                  $SERVER_ROOT/$VH_NAME/
  configFile              $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
  allowSymbolLink         1
  enableScript            1
  restrained              1
  setUIDMode              0
}
/usr/local/lsws/conf/vhosts/sub.domain.com/vhconf.conf:
Code:
docRoot                   $VH_ROOT/public/
vhDomain                  www.domain.com
vhAliases                 sub.domain.com, domain.com
adminEmails               admin@domain.com
enableGzip                1
enableBr                  1

errorlog $VH_ROOT/logs/error.log {
  useServer               0
  logLevel                ERROR
  rollingSize             50M
  keepDays                30
  compressArchive         1
}

accesslog $VH_ROOT/logs/access.log {
  useServer               0
  logHeaders              7
  rollingSize             50M
  keepDays                30
  compressArchive         1
}

index  {
  useServer               0
  indexFiles              index.php
  autoIndex               0
}

errorpage 404 {
  url                     /error.php
}

scripthandler  {
  add                     lsapi:lsphp php
}

expires  {
  enableExpires           1
}

accessControl  {
  allow                   *
}

context exp:.gitignore|.gitkeep {
  location                $DOC_ROOT/$0
  allowBrowse             0
  addDefaultCharset       off
}

rewrite  {
  enable                  1
  autoLoadHtaccess        1
  logLevel                0
}

vhssl  {
  keyFile                 /etc/letsencrypt/live/domain.com/privkey.pem
  certFile                /etc/letsencrypt/live/domain.com/fullchain.pem
  certChain               1
  renegProtection         1
  sslSessionCache         1
  sslSessionTickets       1
  enableSpdy              15
  enableQuic              1
  enableStapling          1
  ocspRespMaxAge          300
  ocspResponder           http://r3.o.lencr.org
}
Is it normal that all events of a certain level end up in the server log in addition to the virtual host log? I would expect VHost logs not to be sent to the server log, especially given that the VHost "Use Server's Log" setting is set to "No".

Example log from the server-level error.log below. It is for the VHost that has Use Server's Log set to No.
2024-02-22 00:49:07.160306 [NOTICE] [107147] [xxx.xxx.xxx.xxx:18434:HTTP2-5#sub.domain.com] [STDERR] PHP Notice: Undefined index: i in /usr/local/lsws/sub.domain.com/public/index.php on line 1428

The same kind of logs for the same VHost are also written to /usr/local/lsws/logs/stderr.log.
So, it turns out that the same kind of PHP Notice can be written to 3 different places simultaneously?

The php.ini file of the LSPHP handler used for the sub.domain.com VHost does not have error_log directive set (the line is commented out), to it should mean the default error log location should be used.

Here is the OpenLiteSpeed server-level log configuration:
File Name logs/error.log
Log Level DEBUG
Debug Level None
Rolling Size (bytes) 10M
Keep Days 30
Compress Archive Yes
Enable stderr Log Yes

How can I configure the PHP Notices to only be logged into the error log of the specific VHost?
 
Last edited:
Top