How to write logs into files?
I can use console.log to show some message.
but how to write logs into files?
It's useful for tracing bugs in different users' device.
I'm not sure what console.log is, but the following works:
myLog << "Log message" << endl;
unclewerner, your solution is pure C++, not QML :)
You can overwrite debug ouput handler (in C++) to write in file and use QML console.log as you use it now and all messages will go to file.
Or you use Qxt's QxtLogger, and let that
a) install itself as the message handler, and
b) output to the file you want, by setting up the appropriate logger engine (either the QxtBasicFileLoggerEngine or the QxtXmlFileLoggerEngine, in your case).
As the above comments indicate, there is no "pure-QML" solution to this problem -- you'll need to do some C++ coding in order to write to a file. This could be done by overriding the message handlers, or exposing you own custom function to QML that takes care of the writing. "This page":http://doc.qt.nokia.com/4.7-snapshot/qtbinding.html#exchanging-data-between-qml-and-c gives more information on some of the ways to communicate between C++ and QML.