You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Piotr Karwasz (Jira)" <ji...@apache.org> on 2022/03/24 13:56:00 UTC

[jira] [Resolved] (LOG4J2-3436) Log4j 2 syslogAppender prints localhost.localdomain instead of actual hostname

     [ https://issues.apache.org/jira/browse/LOG4J2-3436?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Piotr Karwasz resolved LOG4J2-3436.
-----------------------------------
    Resolution: Duplicate

[~ragini],
Thanks for the configuration sample, which clarifies what is the source of the problem.

I believe you are affected by [LOG4J2-3359|https://issues.apache.org/jira/browse/LOG4J2-3359]. Unlike Log4j 1.x, currently the layout you configure using the Log4j 1.2 bridge is used to provide the *entire* content of the SysLog packet (Log4j 1.x used it just for the _MESSAGE_ part of the packet).

Log4j is sending invalid packets to the Syslog server and the server tries to correct them adding (always the same) _PRI_ and _HEADER_ part. It's not Log4j, but the Syslog server that adds {{localhost.localdomain}}.

If this hypothesis is correct, removing the layout configuration will actually fix the hostname problem (and introduce another one :-) ).

> Log4j 2 syslogAppender prints localhost.localdomain instead of actual hostname
> ------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3436
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3436
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders, Log4j 1.2 bridge
>         Environment: Using log4j 2 bridge API: snapshot version of 2.17.3 log4j-1.2-api-2.17.3.jar 
>            Reporter: Ragini Gawande
>            Assignee: Piotr Karwasz
>            Priority: Blocker
>
> We are trying to use syslogAppender for our logging but in the logs its prints localhost.localdomain instead of actual hostname
> <13>Mar 14 22:33:41 *localhost.localdomain* Main[6133] +05:30 2022 572 1 com.test.common.logging.Test |  FINE#com.test.common.logging.Level - Can print FINE
> <13>Mar 14 22:33:41 *localhost.localdomain* Main[6133] +05:30 2022 572 1 com.test.common.logging.Test |  INFO#com.test.common.logging.Level - Can print Info
>  
> Here we are using snapshot version of log4j 2.17.3
> This issue was not seen when using log4j 2.17.1
>  
> Additional info:
> JDK 1.8
> -Dlog4j1.compatibility=true



--
This message was sent by Atlassian Jira
(v8.20.1#820001)