WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / How To Add A Tag (Log prefix) To Syslog Entries

How To Add A Tag (Log prefix) To Syslog Entries

05.07.2013 by William Lam // 2 Comments

Last year I wrote an article on how to forward vCenter Server logs to a remote syslog server using the built in syslog-ng client in the VCSA. A few weeks back, I received an interesting email from Michael White sharing details about adding a "tag" or more specifically, adding a string prefix to each syslog entry being forwarded. This was interesting as it enables a user to easily search for a specific log entry based on a "tag" and comes really in handy when you have multiple log sources being forwarded from the same host. An example of this would be the various logs from a vCenter Server such as vpxd, vws, inventoryservice, etc. which all have their own individual logs coming from the same host.

Within the Syslog-ng client configuration, you can specify the log_prefix() option and the string you wish to prefix a given log source. The tag has a specific syntax that must contain a : (colon) and a whitespace after the string (e.g. "VC_APP: ").

Using the vCenter Server as example, we could add the following tags:
After restarting the syslog-ng client for the changes to going into effect, you can head over to your syslog server to view the updated syslog entries. In the screenshot below, we can see we have log sources from both our VC_APP (vpxd.log) and VC_IS (ds.log) entries as specified in our syslog-ng client configurations.

Note: For newer versions of syslog-ng, program_override() is used instead of log_prefix(). The syntax for that would be program_override("VC_APP").

I want to thank Michael for sharing this cool tidbit!

More from my site

  • Enhanced vCenter Server Audit Event & Logging in vSphere 6.7 Update 2
  • A preview of native syslog support in VCSA 6.0
  • Forwarding vCenter Server Logs to a Syslog Server
  • vCenter Identity Federation with Authelia
  • vCenter Server Identity Federation with Kanidm

Categories // Uncategorized Tags // syslog, tag, VCSA

Comments

  1. *protectedAkshatha says

    09/15/2014 at 7:29 pm

    thanks for the info. How do i add log prefix in syslog-ng_conf if i wnat the string "ABC" to be added if the $program sending message is httpd?

    i have my syslog.conf reading messages from
    file ("/proc/kmsg" log_prefix("kernel: "));
    unix-stream ("/dev/log");
    internal()

    and message is sent as

    template t_filetmpl { template("$ISODATE $FACILITY $HOST $PROGRAM[$PID]: $LEVEL $MSGONLY\n"); template_escape(no); };

    destination d_mesg { file("/var/log/messages" template(t_filetmpl)); };

    log { source(s_syslogng); source (s_internal);
    destination(d_mesg); };

    Reply

Trackbacks

  1. Syslog Agents on Linux - SFlanders.net says:
    12/21/2014 at 2:47 am

    […] Syslog messages can be modified and support the addition of tags making querying easier. For a great example on how and why to tag logs see: http://www.virtuallyghetto.com/2013/05/how-to-add-tag-log-prefix-to-syslog.html. […]

    Reply

Leave a Reply to AkshathaCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025