php - ZF2 ZendLog + Doctrine2
865
I do not know how to configure Zend \ Log with Doctrine2. Only allows you to write directly to the database via a connection adapter or write to a file.
I do not know how to configure Zend \ Log with Doctrine2. Only allows you to write directly to the database via a connection adapter or write to a file.
People are also looking for solutions to the problem: javascript - Ripping off HTML tags and considering line breaks in a textarea
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
Find the answer in similar questions on our website.
Answer
Solution:
May be it's too late to answer this question but better late than never.
I've found a good post which explains how to create a basic
for ZF2 and Doctrine.
The approach is pretty simple :
1. Creating {-code-5} class : Create the following class in your
{-code-2}
folder :The
{-code-4}
function which is called by Doctrine when it finiches sending the query to the database server, is overrided so that it could write the current query to the{-code-5}
object.2. Configuring the {-code-5} : Add the following code in your
{-code-6}
file, to make the {-code-5} accessible to the{-code-7}
using the name{-code-8}
:The
{-code-5}
will write data to the{-code-11}
file. So, make sure that{-code-12}
folder exists in your application root directory.3. Configuring Doctrine : Now you need to tell Doctrine to use the created {-code-5}. Just add the following code to your Doctrine configuration :
Answer
Answer
With the above configuration of
{-code-14}
and{-code-15}
, you'll get all the query data logged in the{-code-16}
file.Please see this Sql Logger for ZF2 and Doctrine for more details.
Answer
Answer