[
https://issues.apache.org/jira/browse/LOG4J2-3359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17480371#comment-17480371
]
Tukesh commented on LOG4J2-3359:
--------------------------------
[~ggregory] - I didn't some debugging here are my findings :-
layout is instantiated to LayoutWrapper so following 2 lines are executed.
if (layout instanceof LayoutWrapper) {
appenderLayout = ((LayoutWrapper) layout).getLayout();
I was expecting following line to get executed where facility is properly
appended.
appenderLayout = SyslogLayout.newBuilder()
.setFacility(Facility.toFacility(facility))
.setConfiguration(configuration)
.build();
Here is relevant function from SyslogAppenderBuilder.java :-
{code:java}
private Appender createAppender(final String name, final Log4j1Configuration
configuration, Layout layout,
String facility, final Filter filter, final String syslogHost,
final String level, final Protocol protocol) {
AtomicReference<String> host = new AtomicReference<>();
AtomicInteger port = new AtomicInteger();
resolveSyslogHost(syslogHost, host, port);
org.apache.logging.log4j.core.Layout<? extends Serializable>
appenderLayout;
if (layout instanceof LayoutWrapper) {
appenderLayout = ((LayoutWrapper) layout).getLayout();
} else if (layout != null) {
appenderLayout = new LayoutAdapter(layout);
} else {
appenderLayout = SyslogLayout.newBuilder()
.setFacility(Facility.toFacility(facility))
.setConfiguration(configuration)
.build();
} {code}
> Facility and priority missing in Syslog message when Syslog log appender and
> pattern layout is used with log4j1-2 bridge API
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-3359
> URL: https://issues.apache.org/jira/browse/LOG4J2-3359
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders
> Environment: This issue is reproducible with log4j-2.17.1 &
> log4j-2-17-2
> JDK 1.8
> -Dlog4j1.compatibility=true
> log4j.properties file :-
> log4j.rootLogger=DEBUG,SYSLOG
> log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
> log4j.appender.SYSLOG.Threshold=DEBUG
> log4j.appender.SYSLOG.SyslogHost=localhost:514
> log4j.appender.SYSLOG.protocol=UDP
> log4j.appender.SYSLOG.Facility=LOCAL1
> log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
> log4j.appender.SYSLOG.layout.ConversionPattern=${hostName} MyMain[%pid] :%t:
> %c %-4p - %m%n
> Reporter: Tukesh
> Priority: Blocker
> Attachments: LoggerExample.java, bug_fac_pri.pcapng,
> bug_fac_pri2.pcapng.pcap, log4j.properties
>
>
> FACILITY and PRIORITY is not included when log4j bridge API sends SysLog
> message. Please find the attached pcap files.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)