Messaging and Logging: Implementation and Intent

Messaging and logging are similar in implementation but different in usage.

Photo by Frank McKenna

Structured Message Format

The implementation of a logging or messaging system can be the same. We recommend you standardize on a Structured Message Format for both logging and messaging.

However, messaging and logging differ significantly by intent.


Logging intends to provide a developer insight into the inner working of a program. Example logs are “Saved to file ‘file_name.txt,’” “Error opening folder,” etc.

The example snippet of code shows a “File Not Found” log message.

import { message } from 'messaging';message.log({
"message": "File 'image.gif' not found.",
"level" : "error",
  • Logs, generally, don’t require processing by a job system.
  • NO Personally Identifiable Information (PPI) — There should be no PPI where logs are stored. Email addresses, passwords, API keys, etc., are all PPI that should be filtered or anonymized.
  • Log content placed in storage for debugging or review at a later time.
  • It is usually ok to “fire-and-forget”: there is no need to `await` when logging. (We can see this in the above code snippet). An error while logging shouldn’t stop a system from running.
  • A log could also become a message: it needs to be processed. For example, an error may require further processing.


A message (message passing) often invokes an action within a software system. Example messages are “Login User,” “User Logged Out,” “Buton Clicked,” etc.
The example snippet of code shows sending an “Invoice Paid” message.

import { message } from 'messaging';try {
await message.send({
"message": "Invoice 'I4536' paid on 01.29.2022.",
"template": "Invoice %{} paid on %{data.paid_on}.",
"topics": ["login"],
"dataSchema" : {
"name": "invoice_paid",
"ver": "1.0.0"
"data" : {
"id": "I4536",
"paid_on": "01.29.2022",
} catch {
// ...
  • A message requires further processing. Processing can generate more messages. We will cover different ways of scaling and processing messages in other posts.
  • Personally Identifiable Information (PPI) — PPI is most likely required to process a message. For example, the “Login User” message may require a user name and password.
  • It’s possible to store messages for re-processing in a persisted message queue like Kafka.
  • It is vital to verify that messages are successfully processed. An error while sending a message may stop a system from running.


Although the underlying message library can be the same for logging and messaging, the handling of messages and logs varies greatly.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eric Hosick

Eric Hosick


Creator, entrepreneur, software architect, software engineer, lecturer, and technologist.