0

I want to use the log - /var/log/message for my logs my application name is - whatsapp_man

for example I send the following warning to the log

[root@worker01 ~]# logger "please noitce you are before attack"
[root@worker01 ~]# tail -1 /var/log/messages
Mar  4 13:28:05 worker01 root: please notice you are before attack
[root@worker01 ~]#

but how to use the logger in order to get whatsapp_man instead of root

as the fowling expected results

[root@worker01 ~]# logger [....] "please notice you are before attack"
[root@worker01 ~]# tail -1 /var/log/messages
Mar  4 13:28:05 worker01  whatsapp_man: please notice you are before attack
[root@worker01 ~]#
Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
yael
  • 12,598
  • 51
  • 169
  • 303
  • its workers , can I ask another question please , let say we want to use the logger on some other log file as /var/log/server.log , is it possible to use loggger to write logs to server.log? – yael Mar 04 '19 at 14:31
  • any please wrote answer to the first question and I will vote for you – yael Mar 04 '19 at 14:31
  • for your commented-question, see https://unix.stackexchange.com/questions/67708/logger-command-how-to-store-logs-in-given-file and/or https://unix.stackexchange.com/questions/434459/logger-f-command-killed-opening-var-log-messages-in-tail – Jeff Schaller Mar 04 '19 at 14:39

1 Answers1

1

The prefix you're looking for is provided by the -t option of logger:

logger -t whatsapp_man "..."
Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250