The `localHostname` field of `SyslogLayout` you are pointing to is constant and not configured by user-provided properties. Feel free to submit a ticket (along with a PR?) to fix this.
But your problem is not that one. When `format` is set to `RFC5424`, `SyslogAppender` uses `Rfc5424Layout` – not `SyslogLayout`! Though there `localhostName` is again populated from `NetUtils.getLocalHostname()`. You can again submit a ticket & PR for this one too. I am not familiar with Papertrail. Can't you simply log JSON to the console or a TCP socket? On Tue, May 2, 2023 at 4:12 AM Ganesh S <ganesh123.g...@gmail.com> wrote: > Hello, > > I'm trying to implement remote logging for my application which is running > in a docker container. > The remote server provider is Papertrail. > I want to specify a custom local host name, currently it is taking > container id, which I don't want. > In syslog layout GitHub link > > https://github.com/apache/logging-log4j2/blob/2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/SyslogLayout.java#L126-L129 > It has a localHostname property or field, which is taking the value from > org > .apache.logging.log4j.core.util.NetUtils.getLocalHostname(). > How to set this attribute. > My current implementation is as follows > AppenderComponentBuilder appenderBuilder = builder.newAppender("syslog", > "Syslog") > .addAttribute("protocol", "UDP") > .addAttribute("host", host) > .addAttribute("port", port) > .addAttribute("appName", serviceName) > .addAttribute("id", serviceName) > .addAttribute("facility", "LOCAL0") > .addAttribute("newLine", true) > .addAttribute("format", "RFC5424") > .addAttribute("ignoreExceptions", false); > > I'm ok to use SocketAppender as well if syslog appender doesn't support > this. > > Thank you, > > Ganesh S >