Technology and General Blog

In UNIX and Linux-kind working programs, the log is a file that documents each individual action of the functioning program. When a user login to the technique, it will save the report in the log file. It also makes it possible for the consumer to include any material to the file.

For this, the term “logger” is the command-line software that supplies a shell command interface and offers the consumer an uncomplicated solution to add logs in the /var/log/syslog files. You can insert entries into the log documents using the “logger” command.

The syntax of this command-line utility is:

How to Use logger Command with Selections:

The “logger” command is a pre-designed instrument in Linux methods. Using this command, people can execute various capabilities with unique options:

Print “syslog” file:

The syslog file performs an critical job in Linux distributions as it merchants all the log knowledge in the /var/log directory.

To view the syslog file in the terminal, execute the subsequent tail command:

Specify the syslog Strains:

The “tail” is utilised to capture the document from syslog files and print it in the terminal. By default, when a tail command is executed, it prints the last 10 log lines of a file. But we can also specify the amount of log traces to print:

$ tail -n 30 /var/log/syslog

Add log into syslog file:

Incorporate any remark in the syslog file through the “logger” command devoid of passing any solution.

$ logger “For_Testing”

Operate the “tail” command to print it on the terminal:

Log “who” Command:

The “logger” command can also be employed to incorporate the common output of any command. Type the “who” with logger command to add it in the syslog file:

Exhibit it with the tail command:

Log Specified File:

The “logger” command allows the consumer to include the content of a specified file into the syslog file employing the “-f” solution.

Let’s produce a file named “examination_file1.txt” and increase some textual content to it:

Now, to print the file log in the terminal, execute the provided command:

$ logger –f examination_file1.txt

Notice: In the tail command, tail -2 usually means that it will print the previous two output lines. But if you want to print the specific output with all the logs, you really don’t need to have to specify the range of lines.

Specify Log Size:

Some loglines can be lengthy strings and limit them to use “–size” choice. Operate the stated “–size” selection in the following way:

$ logger –dimension 12 12345678901122334455……

(In the above command, we additional random figures in the log and displayed the only first 12 figures working with the size possibility. Tail -1 will print only the very last line of the exhibit outcome).

Disregard Vacant Strains:

Use the “-e” possibility if the file consists of vacant strains in it. It will eliminate the blank strains from the file and print the output in the common way.

For case in point, include some blank traces in the text file we produced:

Run the “-e” possibility with the file title “test_file1.txt” to clear away vacant traces:

$ logger -e -f check_file1.txt

Screen Assistance:

Type the “–help” possibility to screen the support information about the “logger” command and its alternatives:


The “syslog” file in each individual process retains a record of every action executed by the running program. There is a “logger” command in the Linux techniques that gives an interface to the person to include logs in the “/var/log/syslog” file working with the terminal.

In this writing, we have mentioned the Linux “logger” command and uncovered the features of its different options as a result of several examples.

Leave a Reply

Your email address will not be published. Required fields are marked *