[ https://issues.apache.org/jira/browse/LOG4J2-3356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17501496#comment-17501496 ]
ruffp commented on LOG4J2-3356: ------------------------------- I managed to make the log4j2 working in OSGI but with pax-logging (master branch of my servicemix-docker github), because they seems to embed the lib `org.apache.logging.log4j.layout.template.json` in their pax.logging implementations. I removed this lib as fragment and used their latest snapshot and the logs are coming in json format. However if I want to test this bug, I have an issue starting servicemix because the log4j-core seems not recognized. I created a specific branch: https://github.com/ruffp/servicemix-docker/tree/test/log4j2-without-pax in my project without pax-logging and trying to add only slf4j (seems max v1.7.25 is compatible) and I used the log4j jars from the build (2.17.3-SNAPSHOT). If someone can tell me what jars need to be added in the startup.properties and in which order to be able to integrate log4j2 in OSGI, I will be able to test it. Error found in logs: {noformat} ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console.. {noformat} Extract of my startup.properties: {noformat} # Bundles to be started on startup, with startlevel mvn\:org.slf4j/slf4j-api/1.7.25 = 5 mvn\:org.apache.logging.log4j/log4j-slf4j-impl/2.17.3 = 5 mvn\:org.apache.logging.log4j/log4j-api/2.17.3 = 6 mvn\:com.fasterxml.jackson.core/jackson-annotations/2.12.4 = 6 mvn\:com.fasterxml.jackson.core/jackson-core/2.12.4 = 6 mvn\:com.fasterxml.jackson.core/jackson-databind/2.12.4 = 6 mvn\:org.apache.logging.log4j/log4j-layout-template-json/2.17.3 = 6 mvn\:org.apache.logging.log4j/log4j-core/2.17.3 = 7 {noformat} I tried to start the log4j-core in different levels but always the same error. > The sub module log4j-layout-template-json seems not properly configured to be > deployed as a fragment host in OSGI > ----------------------------------------------------------------------------------------------------------------- > > Key: LOG4J2-3356 > URL: https://issues.apache.org/jira/browse/LOG4J2-3356 > Project: Log4j 2 > Issue Type: Bug > Components: JsonTemplateLayout > Affects Versions: 2.17.1 > Environment: Tested on ServiceMix (under Docker) 7.0.1, but it should > be the same in Karaf 4.x > I also tried to add the original log4j2-api and log4j-core in the same config > but the fragment never gets resolved. > Reporter: ruffp > Assignee: Volkan Yazici > Priority: Major > Attachments: image-2022-02-01-19-53-38-377.png > > > In the > [pom|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-layout-template-json/pom.xml] > of the module we have: > {code:xml} > <plugin> > <groupId>org.apache.felix</groupId> > <artifactId>maven-bundle-plugin</artifactId> > <configuration> > <instructions> > > <Fragment-Host>org.apache.logging.log4j.layout.template.json</Fragment-Host> > <Export-Package>*</Export-Package> > </instructions> > </configuration> > </plugin> > {code} > The Fragment host seems to refer to itself. > When I tried to deploy this jar as a bundle with this in my > startup.properties file: > {noformat} > mvn\:org.apache.logging.log4j/log4j-layout-template-json/2.17.1 = 5 > mvn\:org.ops4j.pax.logging/pax-logging-log4j2-extra/1.11.13 = 6 > mvn\:org.ops4j.pax.logging/pax-logging-api/1.11.13 = 8 > mvn\:org.ops4j.pax.logging/pax-logging-log4j2/1.11.13 = 8 > {noformat} > And copying the lib in the "system" folder of karaf (I tried with ServiceMix > 7.0.1). > The bundle stays in status "Installed" and never resolves as the > Fragment-Host refers to itself. > I am not sure what values should be set in this as I am using Pax Logging, > but for sure the Host does not seems correct to me (otherwise I would have > created a PR). -- This message was sent by Atlassian Jira (v8.20.1#820001)