[ 
https://issues.apache.org/jira/browse/OFBIZ-6858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16312860#comment-16312860
 ] 

Shi Jinghai commented on OFBIZ-6858:
------------------------------------

I played this issue today. 

OFBiz uses Log4J2 directly for logging, Solr uses SLF4J. According to the 
document from SLF4J (https://www.slf4j.org/legacy.html), SLF4J can be bound to 
Log4J. Log4J is end of life, Solr doesn't upgrade to Log4J2 until now (see 
SOLR-7887 for details).

Here are the steps to make Solr log working in OFBiz trunk:
1. Comment out  log4j-1.2-api and log4j-slf4j-impl in /build.gradle, as 
delegating Solr' logging to Log4J2 wouldn't work.

{code:java}
//    runtime 'org.apache.logging.log4j:log4j-1.2-api:2.10.0' // for external 
jars using the old log4j1.2: routes logging to log4j 2
    runtime 'org.apache.logging.log4j:log4j-core:2.10.0' // the implementation 
of the log4j 2 API
    runtime 'org.apache.logging.log4j:log4j-jul:2.10.0' // for external jars 
using the java.util.logging: routes logging to log4j 2
//    runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.10.0' // for 
external jars using slf4j: routes logging to log4j 2
{code}


2. Add slf4j-api, slf4j-log4j12 and log4j in plugins/solr/build.gradle:

{code:java}
        pluginLibsRuntime 'org.slf4j:slf4j-api:1.7.7'
        pluginLibsRuntime 'org.slf4j:slf4j-log4j12:1.7.7'
        pluginLibsRuntime 'log4j:log4j:1.2.17'
{code}


3. Add log4j.configuration to system properties in /build.gradle:

{code:java}
// java settings
def jvmArguments = ['-Xms128M', '-Xmx1024M', 
        
'-Dlog4j.configuration=file:///D:/workspaces/OFBiz/ofbiz-framework-trunk/plugins/solr/config/log4j.properties']
{code}


4. Copy log4j.properties from Solr repository 
(https://github.com/apache/lucene-solr/blob/releases/lucene-solr/7.1.0/solr/server/resources/log4j.properties),
 change solr.log to runtime/logs/solr

{code:java}
# rootLogger log level may be programmatically overridden by -Dsolr.log.level
solr.log=runtime/logs/solr
log4j.rootLogger=INFO, file, CONSOLE

# Console appender will be programmatically disabled when Solr is started with 
option -Dsolr.log.muteconsole
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} 
%-5p (%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n

#- size rotation with log cleanup.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=4MB
log4j.appender.file.MaxBackupIndex=9

#- File to log to and log format
log4j.appender.file.File=${solr.log}/solr.log
log4j.appender.file.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p 
(%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n

# Adjust logging levels that should differ from root logger
log4j.logger.org.apache.zookeeper=WARN
log4j.logger.org.apache.hadoop=WARN
log4j.logger.org.eclipse.jetty=WARN
log4j.logger.org.eclipse.jetty.server.Server=INFO
log4j.logger.org.eclipse.jetty.server.ServerConnector=INFO

# set to INFO to enable infostream log messages
log4j.logger.org.apache.solr.update.LoggingInfoStream=OFF
{code}

5. Start OFBiz

6. Visit https://localhost:8443/solr/#/~logging and 
https://localhost:8443/solr/#/~logging/level works as expected.


> Solr logging doesn't work
> -------------------------
>
>                 Key: OFBIZ-6858
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-6858
>             Project: OFBiz
>          Issue Type: Bug
>          Components: solr
>    Affects Versions: Trunk, Release Branch 15.12
>            Reporter: Pierre Smits
>            Assignee: Shi Jinghai
>         Attachments: Image2.png
>
>
> When looking at the logging screen in demo-trunk 
> (https://demo-trunk-ofbiz.apache.org/solr/#/~logging) no logging results are 
> shown. Nor does https://demo-trunk-ofbiz.apache.org/solr/#/~logging/level 
> provide any insights.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to