I am trying to send a log message to syslog via
logger -is -t TestApp -p user.error TEST MESSAGE1
Then I check if he is
tail system.log
...
Apr 12 16:33:00 HOSTNAME TestApp[3024]: TEST MESSAGE1
And so it works. Then I try to do the same with a compiled application.
openlog("TestApp", LOG_PID, LOG_USER);
setlogmask(LOG_UPTO(LOG_DEBUG));
syslog(LOG_ERR, "TEST MESSAGE2");
closelog();
I run the application, then check system.log
tail system.log
...
Apr 12 16:33:00 HOSTNAME TestApp[3024]: TEST MESSAGE1
....
and I can not find "TEST MESSAGE 2". I also try to check it through "syslog"
syslog -s -l er TEST MESSAGE3
The same result. I do not see the message in the log file. OK. There may be some problems with the log settings. Therefore, I am trying to configure logging to a specific file. I create / etc / asl / TestApp
# ASL configuration for TestApp
#
> /var/log/TestApp.log mode=0640 format=bsd rotate=seq compress file_max=1M all_max=5M
#
? [= Sender TestApp] file /var/log/TestApp.log
? [= Sender TestApp] [<= Level debug] claim
I am restarting both syslogd and ASL.
launchctl stop com.apple.syslogd
launchctl stop com.apple.aslmanager
launchctl start com.apple.aslmanager
launchctl start com.apple.syslogd
Then I try to send a message through "logger" again and check the logs
tail TestApp.log
Apr 12 16:47:49 HOSTNAME TestApp[3062]: TEST MESSAGE1
, "logger" . , "TEST MESSAGE2". "syslog -s -l er TEST MESSAGE3". TestApp.log system.log.
macOS , , syslog .
? "logger" , "syslog" (Hello World) ?