-->

DEVOPSZONES

  • Recent blogs

    How to use logger Command?

    How to use logger Command?

    The logger is a shell command interface to the syslog system log module. It'll add messages in the /var/log/messages file from the command line and other files. 
    Now Log the message to the Messages file.
    [root@exampleserver ~]# logger Test
    Now Please check the /var/log/messages file, it should display messages as follows:
    Sep 26 09:39:16 exampleserver root: Test
    To Print the Logger process id with message, Use the following Command.
    [root@exampleserver ~]# logger -i Test
    Now Please check the /var/log/messages file, it should display messages as follows:
    Sep 26 09:48:38 exampleserver root[13012]: Test
    To Log a command Output to the /var/log/messages file .
    [root@LINBCK1 ~]# logger `date`
    The message would look like this.
    Sep 27 07:50:03 LINBCK1 root: Thu Sep 27 07:50:03 CEST 2018
    To log the messages in a specific file to /var/log/messages file .
    [root@exampleserver ~]# echo ram >> /var/log/test.log
    Now log that file to Messages file.
    [root@exampleserver log]# logger -f /var/log/test.log

    Now Test if that log is in /var/log/messages or not.
    Sep 26 10:03:28 exampleserver root: ram
     Enter the message with the specified priority.
     logger -p local0.notice Test
     Log the every line in the log with the specified tag.
     [root@exampleserver log]# logger -t tagtst Test
     Now check the Log File for the message with that Tag.
     Sep 26 10:10:50 exampleserver tagtst: Test

    No comments