8

BlackBerry 10 has quite sophisticated logs system compared to iOS and Android. The only solution i found is using javaloader tool like this:

javaloader.exe -u eventlog > eventlog.txt

But it seems to work only with pre-10 versions of BlackBerry OS. I cannot find this tool in BlackBerry 10 NDK.

What is the simplest method to get the logs using the command line?

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
  • Are you tried [this](http://btsc.webapps.blackberry.com/btsc/viewdocument.do;jsessionid=8B65359757AC2078B347497A3AAFF444?externalId=KB34114&sliceId=2&cmd=displayKC&docType=kc&noCount=true&ViewedDocsListHelper=com.kanisa.apps.common.BaseViewedDocsListHelperImpl) solution? – CAMOBAP Aug 06 '13 at 16:50
  • @CAMOBAP: yes, but ``-getFile`` works faster for me. – Sergey K. Aug 07 '13 at 12:52

5 Answers5

9

You can also SSH onto the device (ssh devuser@169.254.0.1) and run:

slog2info -w 

Which will display the slogger2 logs.

donturner
  • 17,867
  • 8
  • 59
  • 81
  • 1
    What needs to be done before you can log in using SSH? I had to add my public RSA key to the authorized_keys2 file using the target file system explorer in Momentics before I could log in. I don't think they meant it to be that complex, so maybe I missed something :) – Wayne Uroda Jan 25 '13 at 05:23
  • 1
    telnet seems to work as well and does not need a key but I did not find the logs useful in my case – Aras Dec 10 '13 at 22:09
6

There are two ways, both documented in the release notes.

If you can copy the logger stream (for an application) to the console by defining a function like:

void myMessageOutput(QtMsgType type, const char* msg) {
    fprintf(stdout, "%s\n", msg);
    fflush(stdout);
}

Then installing it as a message handler:

int main(int argc, char **argv)
{
    Application app(argc, argv);
    qInstallMsgHandler(myMessageOutput);
    ...
}

You can connect to the simulator or device with an ssh system and use the slog2info command.

Melquiades
  • 8,496
  • 1
  • 31
  • 46
Richard
  • 8,920
  • 2
  • 18
  • 24
  • Debug versions built by Momentics will produce a core file. QNX developer support people at BlackBerry events consistently recommend analyzing the core dump in Momentics. – Richard Oct 29 '12 at 15:24
  • 1
    It's the new topic of blackberry devblog: http://devblog.blackberry.com/2012/10/blackberry-10-sdk-console-logging – Benoit Oct 29 '12 at 16:05
  • @Hithredin: any chance to do it without Qt? – Sergey K. Oct 29 '12 at 16:30
  • 1
    I do not know. With native I used Gameplay and their log system, but I haven't see a way to get crash log, etc... – Benoit Oct 30 '12 at 15:24
6

Here is what i have found moving away from Momentics IDE to command line.

When application does printf() the output goes into the file

/accounts/1000/appdata/[your application folder name]/logs/log

You can use this command

blackberry-deploy -getFile [path-to-log]

to bring that file to your PC. Also, you can use target filesystem navigator from the IDE to inspect this (or any other) file.

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
4

This is similar to another answer but with additional details that will be useful for momentics users (BlackBerry 10 IDE)

1. Enable the terminal view in the momentics IDE

Window --> Show view --> Other --> Terminal

Select the terminal and press OK

2. Connect to the terminal

Select the Terminal tab (possibly called 'Terminal 1') in your views window. Select the connect button, it's a green N shaped button on the top right of the top right of the views window.

3. Run the log viewer command

$ slog2info -w

To read more info about this command:

$ slog2info --help 

*Note that there shouldn't be any need to provide an ssh user or keys, that is taken care of by the IDE when you use this procedure.

Log statements

You can add logging to your app with the following commands

qDebug() << "This is debug";
qWarning() << "This is a warning";
qCritical() << "This is critical " << somevariable << ", some additional text";
qFatal() << "This is fatal" << somevariable;
Ray Vahey
  • 3,065
  • 1
  • 24
  • 25
  • Dont u get the same on the console on a debug run??? My app works in debug mode but it crashes in release ....In a release mode I get nothing using the slog2info – becker Aug 10 '15 at 23:31
  • The IDE may have gone through changes since last year. Release is another ball game, I'll update my answer to cover that at the weekend. – Ray Vahey Aug 28 '15 at 11:00
-1

You can view all the logs from the following path

/accounts/1000/appdata/[Application Name]/logs/log
pranavjayadev
  • 937
  • 7
  • 31