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/09/07 18:49:00 UTC
[jira] [Commented] (LOG4J2-3574) Log4j1ConfigurationParser fails to parse SyslogAppender
[ https://issues.apache.org/jira/browse/LOG4J2-3574?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17601473#comment-17601473 ]
Piotr Karwasz commented on LOG4J2-3574:
---------------------------------------
Hi [~TukeshK],
{{Log4j1ConfigurationParser}} is no longer the default way to parse Log4j 1.x configurations.
I have tried to keep in sync the {{Log4j1ConfigurationParser}} with the more modern {{{}PropertiesConfigurationBuilder{}}}, but it is not a sustainable solution.
If you are looking to convert a Log4j 1.x properties configuration to a Log4j2 XML configuration, you might add a {{writeToXml}} method to the [Builder|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-1.2-api/src/main/java/org/apache/log4j/builders/Builder.java] interface and implement it in all builders. It is a lot of work, but it would allow us to deprecate {{Log4j1ConfigurationParser}} in the 3.x series.
> Log4j1ConfigurationParser fails to parse SyslogAppender
> -------------------------------------------------------
>
> Key: LOG4J2-3574
> URL: https://issues.apache.org/jira/browse/LOG4J2-3574
> Project: Log4j 2
> Issue Type: Bug
> Components: Log4j 1.2 bridge
> Affects Versions: 2.18.0
> Reporter: Tukesh
> Priority: Major
> Labels: bridge
>
> WARN StatusLogger Log4j 1 configuration parser: Unknown appender class: org.apache.log4j.net.SyslogAppender; ignoring appender: SYSLOG
> log4j.properties
>
> {code:java}
> log4j.logger.com.test.util=DEBUG, JTAPI_ERROR_APPENDER, SYSLOG
> log4j.additivity.com.avaya.jtapi=false
> log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender log4j.appender.SYSLOG.Threshold=FINEST#org.apache.log4j.helpers.UtilLoggingLevel log4j.appender.SYSLOG.SyslogHost=localhost log4j.appender.SYSLOG.Header=true log4j.appender.SYSLOG.protocol=UDP log4j.appender.SYSLOG.Facility=local0 log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout log4j.appender.SYSLOG.layout.ConversionPattern=DmccMain[%pid] :%t: %c %-4p - %m%n
> {code}
> {code:java}
> try {
> input = new FileInputStream(filePath);
> final ConfigurationBuilder<BuiltConfiguration> builder = new Log4j1ConfigurationParser().buildConfigurationBuilder(input);
> {code}
> Log4j1ConfigurationParser.java
> {code:java}
> private void buildAppender(final String appenderName, final String appenderClass) {
> switch (appenderClass) {
> case "org.apache.log4j.ConsoleAppender":
> buildConsoleAppender(appenderName);
> break;
> case "org.apache.log4j.FileAppender":
> buildFileAppender(appenderName);
> break;
> case "org.apache.log4j.DailyRollingFileAppender":
> buildDailyRollingFileAppender(appenderName);
> break;
> case "org.apache.log4j.RollingFileAppender":
> buildRollingFileAppender(appenderName);
> break;
> case "org.apache.log4j.varia.NullAppender":
> buildNullAppender(appenderName);
> break;
> default:
> reportWarning("Unknown appender class: " + appenderClass + "; ignoring appender: " + appenderName);
> }
> } {code}
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)