[
https://issues.apache.org/jira/browse/SOLR-7887?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15015143#comment-15015143
]
Steve Davids commented on SOLR-7887:
------------------------------------
I believe the best argument for logback is that it is a native implementation
for SLF4j since it is developed by the same group. Though, from both a
configuration and performance perspective the two are very similar. It does
seem the logging .properties files have been frowned upon with the preferred
configuration method being the xml configuration (log4j2 xml is pretty similar
to the logback xml configuration).
This is a pretty useful tool to convert the existing log4j.properties files
over to a logback.xml configuration: http://logback.qos.ch/translator/
So, the
[log4j.properties|https://github.com/apache/lucene-solr/blob/639710b2958ed958f977c64a5fe3bbd5b0b0aa23/solr/server/resources/log4j.properties]
translates to:
{code}
<?xml version="1.0" encoding="UTF-8"?>
<!-- For assistance related to logback-translator or configuration -->
<!-- files in general, please contact the logback user mailing list -->
<!-- at http://www.qos.ch/mailman/listinfo/logback-user -->
<!-- -->
<!-- For professional support please see -->
<!-- http://www.qos.ch/shop/products/professionalSupport -->
<!-- -->
<configuration>
<!-- Errors were reported during translation. -->
<!-- Could not find transformer for org.apache.log4j.EnhancedPatternLayout -->
<!-- Could not find transformer for org.apache.log4j.EnhancedPatternLayout -->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--See also
http://logback.qos.ch/manual/appenders.html#RollingFileAppender-->
<File>${solr.log}/solr.log</File>
<layout class="org.apache.log4j.EnhancedPatternLayout">
<ConversionPattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%X{collection}
%X{shard} %X{replica} %X{core}] %c{1.} %m</ConversionPattern>
</layout>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<maxIndex>9</maxIndex>
<FileNamePattern>${solr.log}/solr.log.%i</FileNamePattern>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>4MB</MaxFileSize>
</triggeringPolicy>
</appender>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="org.apache.log4j.EnhancedPatternLayout">
<ConversionPattern>%-4r %-5p (%t) [%X{collection} %X{shard} %X{replica}
%X{core}] %c{1.} %m%n</ConversionPattern>
</layout>
</appender>
<logger name="org.apache.zookeeper" level="WARN"/>
<logger name="org.apache.hadoop" level="WARN"/>
<logger name="org.apache.solr.update.LoggingInfoStream" level="OFF"/>
<root level="INFO">
<appender-ref ref="file"/>
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
{code}
It does a decent job but for this particular case the translator doesn't know
org.apache.log4j.EnhancedPatternLayout should be translated from:
{code}
<layout class="org.apache.log4j.EnhancedPatternLayout">
<ConversionPattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%X{collection}
%X{shard} %X{replica} %X{core}] %c{1.} %m</ConversionPattern>
</layout>
{code}
to:
{code}
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%X{collection} %X{shard}
%X{replica} %X{core}] %c{1.} %m</pattern>
</encoder>
{code}
(Note: default encoder is PatternLayoutEncoder)
So after that replacement it would actually end up looking like:
{code}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${solr.log}/solr.log</File>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%X{collection} %X{shard}
%X{replica} %X{core}] %c{1.} %m</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<maxIndex>9</maxIndex>
<FileNamePattern>${solr.log}/solr.log.%i</FileNamePattern>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>4MB</MaxFileSize>
</triggeringPolicy>
</appender>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%X{collection} %X{shard}
%X{replica} %X{core}] %c{1.} %m</pattern>
</encoder>
</appender>
<logger name="org.apache.zookeeper" level="WARN"/>
<logger name="org.apache.hadoop" level="WARN"/>
<logger name="org.apache.solr.update.LoggingInfoStream" level="OFF"/>
<root level="INFO">
<appender-ref ref="file"/>
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
{code}
> Upgrade Solr to use log4j2 -- log4j 1 now officially end of life
> ----------------------------------------------------------------
>
> Key: SOLR-7887
> URL: https://issues.apache.org/jira/browse/SOLR-7887
> Project: Solr
> Issue Type: Task
> Affects Versions: 5.2.1
> Reporter: Shawn Heisey
>
> The logging services project has officially announced the EOL of log4j 1:
> https://blogs.apache.org/foundation/entry/apache_logging_services_project_announces
> In the official binary jetty deployment, we use use log4j 1.2 as our final
> logging destination, so the admin UI has a log watcher that actually uses
> log4j and java.util.logging classes. That will need to be extended to add
> log4j2. I think that might be the largest pain point to this upgrade.
> There is some crossover between log4j2 and slf4j. Figuring out exactly which
> jars need to be in the lib/ext directory will take some research.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]