# ListenPortFileName

Writes the port chosen for the diagnostic listener to the named file.

This parameter applies to imdiag: Diagnostic instrumentation.

Name:

  ListenPortFileName

Scope:

  input

Type:

  string (filename)

Default:

  input=none

Required?:

  yes

Introduced:

  at least 5.x, possibly earlier

## Description

Specifies a file that receives the TCP port number after the listener starts. Use ServerRun to initialize the listener. The parameter is mandatory and must be provided before the listener is created.

The file is overwritten each time the listener starts. When the listener is configured with port `0` (ephemeral port selection), this file is the only way to discover the actual port allocated by the operating system.

## Input usage

    module(load="imdiag")
    input(type="imdiag"
          listenPortFileName="/var/run/rsyslog/imdiag.port"
          serverRun="0")

### Legacy names (for reference)

Historic names/directives for compatibility. Do not use in new configs.

- $IMDiagListenPortFileName — maps to ListenPortFileName (status: legacy)

## See also

See also imdiag: Diagnostic instrumentation.

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.