Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Issue

It is a good idea to occasionally save the php.log file and start a new one, to help prevent the log from growing too large.  Linux users can use the logrotate utility to do this, but there is no logrotate utility on the IBM i.  This article describes a simple method to periodically rename the php.log file and let a new one be created.

Environment

Zend Server for IBM i on any supported version of IBM i running Zend Server 9.x - 2019.0.x

One simple way to rotate the php.log file is with a CL program set up to run in the IBM Job Scheduler. The source for the CL program could look like this:

No Format
PGM
DCL        VAR(&TIMESTAMP) TYPE(*CHAR) LEN(20)
DCL        VAR(&NEWNAME) TYPE(*CHAR) LEN(30)
RTVSYSVAL  SYSVAL(QDATETIME) RTNVAR(&TIMESTAMP)
CHGVAR     VAR(&NEWNAME) VALUE('php.log.' *CAT &TIMESTAMP)
RNM        OBJ('/usr/local/zendphp7/var/log/php.log') +
             NEWOBJ(&NEWNAME)
ENDPGM


This will append a timestamp to the end of the php.log file name. The next time PHP needs to write a php.log entry, it will create a new php.log file.  You can run this CL program periodically using the Job Scheduler. Once a week might be a good choice. 

Once in a while go to the /usr/local/zendphp7/var/log directory and delete the old renamed files.

Previous versions:


Note
titleNote: For Zend Server 6 - 8.x customers

The location of the php.log file is /usr/local/zendsvr6/var/log/php.log.  Please adjust the above CL source accordingly.


Note
titleNote: For Zend Server 5 customers

The location of the php.log file is /usr/local/zendsvr/var/log/php.log.  Please adjust the above CL source accordingly.


To learn how to adjust the error_level setting so that the php.log file grows more slowly, please take a look at this article:


Set error_reporting to control error reporting levels in the php.log file




Content by Label
showLabelsfalse
max5
spacesSUPPORT
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ("zend-server","zend","ibm","ibm-i","ibmi","php-log") and type = "page" and space = "SUPPORT"
labelszend zend-server ibm ibm-i ibmi php-log


Page properties
hiddentrue


Related issues