You can use the PacketViewer addon for that. Load it and type the following to log packet contents to a file:
//pv log file 0x01E 0x01F 0x020 0x050
This will log every occurrence of any of those packets to a file. Instead of file you can also log to console or to chatlog. You can also shorten it to //pv l f [list of packet IDs]. If you want to log all but a certain set of packets, you can do //pv log file not [list of IDs].
You can also make the packet appear on screen in a text box and record previous packets then scroll through them:
//pv track incoming 0x017; pv rec
Then send yourself a few tells, you'll see a box appear with the packet dissected. To view previously tracked packets do //pv display n, where n is the index of the packet to display. If you tracked incoming 0x017 (the packet containing chat-info) and had 5 such packets come in, you can do //pv display 4 to show the fourth such packet. You can also hover over the display box and use the mouse wheel to scroll through all the previous packets.