0

I created a simple desktop entry for all users /usr/share/applications/pycharm-foo.desktop

[Desktop Entry]
Name=PyCharm foo
Icon=/usr/share/pixmaps/python2.7.xpm
Exec=pycharm-wrapper foo
Terminal=false
Type=Application
Categories=Application

The application gets found via windows-key (launcher/dash).

But if the application fails with a message on stdout/stderr, then I would like to look at this message.

Where can I find error messages of failed application starts?

guettli
  • 1,777
  • Does it produce stdout/stderr at all if you just run pycharm-wrapper foo ? If yes, you may want to consider wrapping it into a shell command. Something like bash -c 'exec 2>/home/guettli/foo.error.log; pycharm-wrapper foo' – Sergiy Kolodyazhnyy Dec 15 '19 at 00:13
  • @SergiyKolodyazhnyy yes, it does produce output on stderr. I know that I could write a wrapper. But I don't understand why this is needed. This is a fundamental issue which is unclear. I like linux on servers very much. But on the desktop .... – guettli Dec 16 '19 at 11:33
  • Fundamental reason is the design of how .desktop files work. Desktop just spawns a subprocess and executes whatever command you put into Exec= line, and the desktop environments are not required to keep track of stdout/stderr since there's no shell/controlling terminal attached. They could implement that, there's no restriction, but there's no requirement either. Unity did keep track of process crashing, and would show crash dump of the process, for python commands - a traceback or exceptions. Other desktops - I've never seen such feature. – Sergiy Kolodyazhnyy Dec 19 '19 at 06:32
  • @SergiyKolodyazhnyy thank you for the explanation. Soon I will work with Mac. I am curious how they hide errors messages, too. I love Linux .... for servers. I dreamed since 1996 that Linux will be usable on the desktop. I'm not in the mood anymore. – guettli Dec 19 '19 at 10:17

4 Answers4

2

This question is probably a duplicate of:

There are two answers there:

  • Check the contents of ~/.xsession-errors log and,
  • Redirect output when calling command: command >~/log/command.out.log 2>~/log/command.err.log

Also if the process ID is known look at it's file descriptor 1 for stdout and 2 for stderr. This is described in detail in Unix & Linux:

To briefly summarize the top-voted answer:

lsof -p1234 | awk '$4 ~ /^[12][^0-9]/'
ls -l /proc/1234/fd/[12]

Of course the most common method is to simply call the GUI from the command line and your terminal window will show warning and error messages:

$ zenity --info --text "Hello World"
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
1

Well,

the only folder where logs are written is normally /var/log. In your case, the information your looking for could be at different places, because the developer can choose different ones, or might have decided to write logs to his/her own place.

It might be in /var/log/syslog - In syslog are all logs which derive from the system itself, but also programs which were programmed to write into syslog directly.

Then there should be something like /var/log/gdm3 - This is the logfile of the gnome window manager. So if gnome recognises smtg. or has problems itself, it would write it down there.

Did you consider to write it down to your own folder? You could simply append a logfile to your command and then the data would be written in there (according on how you set it up).

This is the second time I link to this today, lol. Look here, as you are using a python application (looks like it), this link should serve you well my friend. Give it a try.

Try to start your python wrapper like this pycharm-wrapper foo &>> /home/$(whoami)/mylogfile.log

Next time before you start, make sure to tail this. Open up a console and type in tail -f /home/($whoami)/mylogfile.log. THEN start you python wrapper and take a look at the console, if errors are displayed.

How do I save terminal output to a file?

s1mmel
  • 2,024
  • ps. if the file is not present yet, your tail command might be sying so. Easy to fix just do a touch /home/$(whoami)/mylogfile.log) – s1mmel Dec 12 '19 at 12:28
  • In the above question the messages get written to stdout and stderr. You say "the developers can chosse". I think this does not apply here. – guettli Dec 12 '19 at 16:15
  • @guettli this is meant in general. If it's not his own project/program/script there might be a logfile setup in the code, hence the general reference. you always have to keep that in mind, that's also why I mentioned the gnome log, could be a problem with the window manager, who knows. – s1mmel Dec 12 '19 at 16:21
0

Nowhere that I can find documented and as already stated you'll get inconsistent results depending on the logging choices the developer of the program made. Perhaps they send errors to stderr, perhaps to stdout, perhaps it returns non-zero on error or perhaps it doesn't. Maybe you get pages of stack trace uselessness that won't fit in a dialog box.

I had a little success with a bash script wrapper that runs the command line you pass it and sends all output to a notification:

notify-send "$($* 2>&1)"

I'd expect inconsistent results though.

David S
  • 131
-1

Honestly what I would do is just use the following:

sudo su root

updatedb

cd /var/log

grep pycharm * > results.txt

cat results.txt

This should tell you which files where pycharm is mentioned in the logs then from that you could even filter further with something like:

cat results.txt | grep *error*

Maybe use fail or die instead of error to try to narrow down the results.

Taux1c
  • 76
  • Why sudo su root? – guettli Dec 19 '19 at 10:18
  • You may not need to on your system. My system only allows super users to access error logs. – Taux1c Dec 19 '19 at 12:36
  • Why updatedb? – guettli Dec 19 '19 at 12:46
  • 1
    That’s actually no longer necessary. I had another step in there using locate but I decided that probably wouldn’t be the best way to go so I took it out and forgot to take out update TV That’s actually no longer necessary. I had another step in there using locate but I decided that probably wouldn’t be the best way to go so I took it out and forgot to take out updatedb. – Taux1c Dec 19 '19 at 12:48
  • But you could run it anyway. It never hurts to index your files. – Taux1c Dec 19 '19 at 12:49
  • 1
    Why should I do things which are not needed? – guettli Dec 19 '19 at 13:20
  • You can run it or not run it. It doesn’t matter it won’t hurt anything. All it does is update the index of files so that when you use locate it has an updated database to search – Taux1c Dec 19 '19 at 21:05
  • 1
    I don't understand why I should do things which are not needed. – guettli Dec 20 '19 at 08:40
  • @Taux1c: You should only concentrate on commands, needed to get the job done. A beginner would like to know what the task at hand updatedb is solving. Yes, it might be of use in general, like opening an editor, controlling /etc/passwd but it is not related to the question and therefor unneeded complexity, only disturbing user in search for an answer. Remove it, and I will remove my downvote. Or defend it with arguments. The same applies for sudo: You don't need to write to /var/log, but to read, and therefore not to cd. grep pycharm /var/log/* | tee results.txt is all what is needed-isnt it? – user unknown Jan 30 '20 at 10:50
  • using grep (in the directions) searches the database, if the database isn't up to date it may not find everything you a searching for thus missing critical information. Thus the updatedb should be executed first to insure the most up to date records. – Taux1c Jan 30 '20 at 10:59
  • User unknown after reading your comment it’s quite obvious you do not understand the question. You should re read it. The user is asking for error messages of pycharm. My approach gets all results and saves them in the error directory. Because adding a bunch of directories can go wrong. If you work in one directory it’s easier for new users. Also on some systems the /var/log is protected and only allows for su access. Thus I believe it is you that is over complicating and confusing the user. Bottom line is my answer works. You may not like the methods and may not agree with it but it works. – Taux1c Feb 05 '20 at 06:12