Yii::log from forked thread does not log


I'm forking serveral threads (using pcntl_fork) of a Yii CConsoleCommand based program. The launched threads use Yii classes such as CdbConnections and a number of CApplicationComponent based classes of my own without any problems. However calling Yii::log from the threads does not log anything. Any pointers as to where to look?



Did you list 'log' in 'preload' of your app config?

Yes the log array is ok, main CConsole app logs fine.

Problem seems to be there is no log->flush method. The threads run till they signal the parent (via a shared mem segment - see Pear-Fork) that they are ready. The parent then posix_kills them. This means the log-array for the thread is never flushed to disk.

I guess best way around this (and to also not run out of memory when running php CConsoleCommand based background apps that log a lot of info) is to write a flushing CFileLogger.

Do you mean the child threads are ended abruptly?

uhhmm yes :(

It tried adding CApplication::end() to the stop function before it calls the posix_kill

But the Threads are children of an ExecuteThread class so no go. (unless I'm mistaken that is) And also I sometimes want the thread to remain running so I can throw some more work at it.

maybe register a shutdown function?