# Legacy `$template` statement

Historic syntax supporting only string templates. Kept for compatibility with older configurations. .. summary-end

Legacy format provides limited functionality but is still frequently encountered. Only string templates are supported with the syntax:

    $template myname,<string-template>

Here myname is the template name (similar to `name="myname"` in the modern format) and `<string-template>` is the same as the `string` parameter in modern templates.

Example modern template:

    template(name="tpl3" type="string"
             string="%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
            )

Equivalent legacy statement:

    $template tpl3,"%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"

Support: rsyslog Assistant | GitHub Discussions | GitHub Issues: rsyslog source project

Contributing: Source & docs: rsyslog source project

© 2008–2025 Rainer Gerhards and others. Licensed under the Apache License 2.0.