---
title: "Global and environmental variables"
url: "https://axoflow.com/docs/axosyslog-core/4.28/chapter-configuration-file/config-global-variables/"
last_modified: "2026-09-24T12:23:53+02:00"
---

> For the complete documentation index, see [llms.txt](https://axoflow.com/docs/axosyslog-core/4.28/llms.txt).

# Global and environmental variables

You can define global variables in the configuration file. Global variables are actually `name-value` pairs. When `syslog-ng` processes the configuration file during startup, it automatically replaces `name` with `value`. To define a global variable, use the following syntax:

```shell
   @define name "value"
```

The value can be any string, but special characters must be escaped (for details, see [Regular expressions](https://axoflow.com/docs/axosyslog-core/4.28/chapter-manipulating-messages/regular-expressions/index.md)). To use the variable, insert the name of the variable enclosed between backticks (`` ` ``, similarly to using variables in Linux or UNIX shells) anywhere in the configuration file. If backticks are meant literally, repeat the backticks to escape them. For example:

```shell
``not-substituted-value``
```

The value of the global variable can be also specified using the following methods:

- Without any quotes, as long as the value does not contain any spaces or special characters. In other words, it contains only the following characters: `a-zA-Z0-9_.`.
- Between apostrophes, in case the value does not contain apostrophes.
- Between double quotes, in which case special characters must be escaped using backslashes (`\\`).

> **Note:**
>
> The environmental variables of the host are automatically imported and can be used as global variables.
>
> In AxoSyslog 3.24 and later, the location of the configuration file is available as the `syslog-ng-sysconfdir` variable.

## Example: Using global variables

For example, if an application is creating multiple log files in a directory, you can store the path in a global variable, and use it in your source definitions.

```shell
   @define mypath "/opt/myapp/logs"
    source s_myapp_1 {
        file("`mypath`/access.log" follow-freq(1));
    };
    source s_myapp_2 {
        file("`mypath`/error.log" follow-freq(1));
    };
    source s_myapp_3 {
        file("`mypath`/debug.log" follow-freq(1));
    };
```

The AxoSyslog application will interpret this as:

```shell
   @define mypath "/opt/myapp/logs"
    source s_myapp_1 {
        file("/opt/myapp/logs/access.log" follow-freq(1));
    };
    source s_myapp_2 {
        file("/opt/myapp/logs/error.log" follow-freq(1));
    };
    source s_myapp_3 {
        file("/opt/myapp/logs/debug.log" follow-freq(1));
    };
```

Last modified September 24, 2026: [Formatting fixes (41ac3715)](https://github.com/axoflow/axosyslog-core-docs/commit/41ac3715900e38f2bf235a3894033ec13edc4b72)
