Lead Image © Andrey Prokhorov, Fotolia.com

Lead Image © Andrey Prokhorov, Fotolia.com

Adding your own information to syslog

Custom Log

Article from ADMIN 90/2025
By
With logger, you can store user-specified messages in syslog to gather information for HPC admin tasks.

HPC administrators periodically look through the system logs in /var/log, searching for errors or other interesting information. Although it is very nice that the logs are centralized and that admins have tools that use these logs to provide notifications, they are not easy to process and understand. Wouldn't it be nice to be able to put your own information into the system log (/var/log/syslog) so you can parse it for your messages with common tools such as grep? Of course, Linux has a tool for that: logger.

The system log is a central location for all system messages and would be a convenient location for storing your own messages. Any automatic log processing tool will catch these messages, but you can easily set up a simple grep to capture the messages you publish to syslog either manually or in scripts. This capability allows you to use all kinds of logging as part of your system administration, including adding logger entries into the system log. The logger entries can be done manually or incorporated into scripts.

Introduction to Logger

All of the examples in this article are from a rather dated Ubuntu 20.04 system, although logger works the same way on current distributions. The basic syntax to write a simple message to the system log is pretty easy:

$ logger "Just a test"

The entry in syslog will include a timestamp indicating when the message was written to the system log, the name of the system, the user who wrote the message or the tag used to write the message, and, after a colon, the message itself:

...
Jun 28 12:24:55 laytonjb-Nitro-AN515-55 laytonjb: Just a test
...

This capability is really simple but very powerful. You can create the message as part of a script (e.g., a Bash

...
Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Logger in HPC System Administration

    Store user-specified messages in syslog with logger.

  • The logging module in Python
    Logging frameworks are a good idea, even for DIY scripts, because they allow programmers to redirect program messages to logfiles. Python developers can turn to the logging module described here.
  • System logging for data-based answers
    To be a good HPC system administrator for today's environment, you need to be a lumberjack.
  • System Logging for Data-Based Answers

    To be a good HPC system administrator for today’s environment, you need to be a lumberjack.

     

  • Gathering Data on Environment Modules

    Gathering data on various aspects of your HPC system is a key step toward developing information about the system and one of the first steps toward tuning your system for performance and reporting on system use. It can tell how users are using the system and, at a high level, what they are doing. In this article, I present a method for gathering data on how users are using Environment Modules, such as which modules are being used, how often, and so on.

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs



Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>
	</a>

<hr>		    
			</div>
		    		</div>

		<div class=