How to print to logread?
I make myself program.
How to output/print to
Who logs? The syslogd acts as the server and any program can act as the client and send log messages to it. For example logger can be used to manually write messages to the system log. Some scripts in /etc/init.d/ actually use this.
In the Omega2's shell:
root@Omega-C465:~# logger -h logger: unrecognized option: h BusyBox v1.25.1 () multi-call binary. Usage: logger [OPTIONS] [MESSAGE] Write MESSAGE (or stdin) to syslog -s Log to stderr as well as the system log -t TAG Log using the specified tag (defaults to user name) -p PRIO Priority (numeric or facility.level pair)
When doing e.g.
root@Omega-C465:~# logger -t "myapp" "Hello World!"
root@Omega-C465:~# logread [..] Sun Jun 24 18:21:20 2018 user.notice myapp: Hello World!
@Maximilian-Gerhardt BIG THANKS!!!
And how to write to logread from python?
In Python2 you can just use the
subprocesslibrary to invoke a shell command as if you would type it in the shell. See https://stackoverflow.com/questions/89228/calling-an-external-command-in-python
from subprocess import call call(["logger", "-t", "myapp", "my test message"])
from subprocess import call
call(["logger", "-t", "myapp", "my test message"])