Using qDebug to write to an external file
I would like to use qDebug in my application, and have it write to an external Log file. This way I can check for messages when the application is running in 'release' mode.
The version of Qt I am using is 3.3.5 (:oI know it is outdated et al, but my project is on it). The qDebug notes in QtAssistant doesn't provide information on writing to an external file. I would like to know if this is possible, and how to do it.
Thanks in advance.
Re: Using qDebug to write to an external file
As written in QtAssistant, qDebug() calls the message handler and if no message handler has been installed, the message is simply printed on stderr. Thus you can either redirect stderr to a file while executing your application or install your custom handler.
Can't you just use QFile class?
Re: Using qDebug to write to an external file
Thanks calhal for your input.
Yes I can use QFile, but was wondering whether there was an inbuilt functionality in qDebug where I can both write to file as well as send it to output. So that it can be used both for release and debug modes of the application.
Well it looks like I will just need to stick to QFile instead. Thanks anyways!
Re: Using qDebug to write to an external file
Make a custom message handler as suggested by calhal.
Re: Using qDebug to write to an external file
Thank you both for the suggestions.
Appreciate it.:)