I've got an obeserver that is run inside a transaction. It's writing log data to database.
My problem is that these log entries are missing if the transaction aborted. Is there any way to have $model->save()
ignore a surrounding transaction? Is it possible to have a model use a second connection to the main Magento database without duplicating configuration?
1 Answer
I wouldn't log into database, but if you have to:
The most simple option would be make a background job for writing logs into database:
- Create a new cache entry with your log with specific cache tag
- Create a cron jobs that finds all cache entries by this tag and writes them to database, then deletes them
Or simply use a standard logging mechanism, with file appending. Then parse log file into database table for searching.