I am a relatively new PHP programmer; my background is Java. My question is trying to register a function call and exit record using Log4PHP. I follow the free MVC template where I have PHP pages that render the view, PHP scripts act as controllers and PHP classes representing the model.
This is what happens: I have a form that obeys the PHP controller, which then creates the PHP class. The newly created object inserts into MySQL, returning a new auto increment identifier. Then control passes to the controller, which switches to another PHP view using the header-> location. Finally, the new PHP view makes a choice in the newly created identifier.
The problem is that during this execution process, ONLY the search is performed by Log4PHP; INSERT - no. Here are some snippets:
<appender name="myConsoleAppender" class="LoggerAppenderConsole" />
<appender name="myLoggerAppenderDailyFile" class="LoggerAppenderDailyFile">
<layout class="LoggerLayoutPattern">
<param name="conversionPattern" value="%d{Y-m-d H:i:s} [%p] %c: %m (at %F line %L)%n" />
</layout>
<param name="file" value="file-%s.log" />
<param name="datePattern" value="Y-m-d" />
</appender>
<logger name="merchant">
<appender_ref ref="myLoggerAppenderDailyFile" />
</logger>
<root>
<level value="DEBUG" />
<appender_ref ref="myConsoleAppender" />
</root>
</configuration>
Constructor:
public function __construct() {
.
.
Logger::configure('config.xml');
$this->log = Logger::getLogger(__CLASS__);
}
Two methods:
public function insertMerchant() {
$this->log->debug("Inserting new Merchant");
.
.
$this->log->debug("Merchant Inserted; ID = $merchantId");
}
public function findMerchantByUserId($userId) {
$this->log->debug("Finding Merchant with userId = $userId");
.
.
$this->log->debug("Merchant found with userId = $userId");
}
As I mentioned, ONLY the LAST call to findMerchantByUserId ($ userid) is written to the file. The insert is never registered,
Thanks in advance for your help.
source
share