How can I read NotifyOSD messages after they are displayed?

You can install the package indicator-notifications which keeps track of notifcations that you receive. You can install with the following

sudo add-apt-repository ppa:jconti/recent-notifications
sudo apt-get update
sudo apt-get install indicator-notifications

You'll have to log out and log back in. It shows up as a mailbox in the top panel and turns green when you get new messages.

Notifications

This is on 13.04 but should work on 12.04 as well.


After carefully looking around (A LOT) I found a code change in 2011 about making notify-osd not output by default to the log file because this was used for debugging purposes and wrote to the HDD every time it did. To activate this feature you can do it 2 ways, a temporary method and a more permanent one.

Temporary Method

Open the terminal I type the following:

For 64 Bit Systems:

sudo killall notify-osd
LOG=1 /usr/lib/x86_64-linux-gnu/notify-osd &

For 32 Bit Systems:

sudo killall notify-osd
LOG=1 /usr/lib/notify-osd/notify-osd &

Now you will see the .cache/notify-osd.log file and the debug information in it.

Permanent Method (WARNING: Global Change)

For a more permanent solution do the following (Global Change. Read the Warning mentioned by Rinzwind below. This will affect everyone and kill the cat!):

sudo nano /etc/environment

Add the following line at the end and save:

LOG=1

Reboot the computer to test.

Permanent Method (User Specific Change)

For a more permanent solution do the following (User specific Change. This will only affect you and the dog. The cat will still survive.):

sudo nano ~/.bashrc

Add the following line at the end and save:

LOG=1

Reboot the computer to test.

You should see the information start to appear in the .cache/notify-osd.log file. For example, this me after disconnecting 2 times my wired connection:

GNU nano 2.2.6 File: .cache/notify-osd.log

[2013-05-04T18:49:55-00:00, NetworkManager ] Connected
Intel

[2013-05-04T18:50:26-00:00, NetworkManager ] Disconnected - you are now offline
Ethernet network

[2013-05-04T18:50:29-00:00, NetworkManager replaced] Connected
Intel

This will show all notification messages from the time it is started until it is stopped.

dbus-monitor "interface='org.freedesktop.Notifications'"    |     \
grep --line-buffered  "member=Notify\|string"

Copy and paste it into a terminal window (Ctrl+Alt+T) .

To stop it use Ctrl+C or close the window.

This is effective though non-discriminating and crude but can be finessed to just monitor the exact details desired, of a specific notifying agent by altering the grep regular expression "member=Notify\|string". The text can then be massaged with sed, awk etc. to look good.

Penultimately, binding the script to automatically execute with the agent of choice to be monitored would be most useful.

cross reference:
- explicit details in Is there a way to view notification history?