There is a special character device named
/dev/kmsg in Linux which provides userspace access to kernel's printk buffer.
You can write to
/dev/kmsg (you need write permission) like that:
echo "Test message" > /dev/kmsg
After the command you see the "Test message" with monolithic time on left in
It is also valid to read from
/dev/kmsg device file, you can read it from your program.
Please note that, printk buffer implemented as a ring buffer and it is generally limited with 128Kb. You can also change this limit on kernel compilation.