First thing is first: whenever I read "it crashed" with no more information I have to facepalm a little bit. If that's all you know, you stopped troubleshooting way too soon. The FireBreath project has a page on debugging plugins that may help, but if you let it crash while a debugger is attached you should find out where it crashed and what the crash was.
I also want to warn you that I've had some significant performance problems with trying to do what you're doing in a production environment; don't use this as your main logging method! it's not fast enough for that.
That said, I don't see anything inherently wrong with your approach for the most part. It could be that your (presumably global) npp_
isn't valid, or it's possible that your string needs to be made up of memory allocated by NPN_MemAlloc; I know that if you were returning it then it would need to be, but I don't think it needs to be when you're just calling a new function; it's something to try, though.
If I were you, my next step would be to attach a debugger and see where the crash is. The easiest way to do that is probably to turn off plugin ipc in firefox so you can easily just attach to the process, but you could also just find the correct process and connect to it (see the debugging page I linked earlier for details)