mesg[n] = 0; is wrong
If recvfrom returns 1024, your're indexing into memory outside what you should.
Same thing if recvfrom returns -1.
Make sure you handle both those cases.
You'll want to make sure sockfd actually has the correct value of your socket, syslog opens a socket too, if you have some error somewhere and start reading from that file descriptor instead, odd things will happen.