Hi,

you have an import-package with !* so you import nothing.
My guess, that is wrong as it should actually import something as it can't
call the desired class.
You should make sure your own bundle/fragment does import the correct
packages.

regards, Achim


2016-02-29 11:18 GMT+01:00 Debraj Manna <[email protected]>:

> Thanks Achim for replying.
>
> I tried to have a fragment bundle of  JSONEvenLayout
> <https://github.com/logstash/log4j-jsonevent-layout> . But whenever I am
> trying to start Karaf I am getting the below exception. I have listed down
> all the steps that I have been doing. Can you let me know what I am doing
> wrong?
>
> ]log4j:ERROR Could not instantiate class [net.logstash.log4j.
> JSONEventLayoutV1].
> java.lang.ClassNotFoundException: net.logstash.log4j.JSONEventLayoutV1
> not found by org.ops4j.pax.logging.pax-logging-service [5]
>     at
> org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
>
>     at
> org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
>
>     at
> org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
>
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>     at java.lang.Class.forName0(Native Method)
>     at java.lang.Class.forName(Class.java:264)
>     at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
>     at
> org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:326)
>
>     at
> org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
>
>     at
> org.apache.log4j.PaxLoggingConfigurator.parseAppender(PaxLoggingConfigurator.java:129)
>
>     at
> org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)
>
>     at
> org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
>
>     at
> org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
>
>     at
> org.apache.log4j.PaxLoggingConfigurator.doConfigure(PaxLoggingConfigurator.java:72)
>
>     at
> org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:214)
>
>     at
> org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImpl.java:362)
>
>     at
> org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)
>
>     at
> org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)
>
>     at
> org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)
>
>     at
> org.apache.felix.cm.impl.ConfigurationManager$UpdateConfiguration.run(ConfigurationManager.java:1747)
>
>     at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:103)
>     at java.lang.Thread.run(Thread.java:745)
> log4j:ERROR No layout set for the appender named [out].
>
>
>
> The steps that I have followed.
>
> 1. Modified the pom.xml file of jsonevent-layout as shown below:-
>
> <plugin>
> <groupId>org.apache.felix</groupId>
> <artifactId>maven-bundle-plugin</artifactId>
> <version>2.3.7</version>
> <extensions>true</extensions>
> <configuration>
>     <instructions>
>         <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
>
> <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
>         <Import-Package>!*</Import-Package>
>
> <Fragment-Host>org.ops4j.pax.logging.pax-logging-service;bundle-version="[1.6,1.7)"</Fragment-Host>
>
> <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
>         <Implementation-Version>${project.version}</Implementation-Version>
>     </instructions>
> </configuration>
> </plugin>
>
> 2. Build json format using mvn clean install -Pbundle
>
> 3. Copy bundle created to system directory
>
>     mkdir -p 
> ${karaf.home}/system/net/logstash/log4j/jsonevent-layout/1.8-SNAPSHOT/
>
>     cp target/jsonevent-layout-1.8-SNAPSHOT.jar
> ${karaf.home}/system/net/logstash/log4j/jsonevent-layout/1.8-SNAPSHOT/
>
> 4. Add this line to etc/startup.properties before Pax Logging
>     
> net/logstash/log4j/jsonevent-layout/1.8-SNAPSHOT/jsonevent-layout-1.8-SNAPSHOT.jar=3
>
>     mvn\:org.ops4j.pax.url/pax-url-aether/2.4.1 = 5
>     mvn\:org.ops4j.pax.url/pax-url-wrap/2.4.1/jar/uber = 5
>     mvn\:org.ops4j.pax.logging/pax-logging-api/1.8.4 = 8
>     mvn\:org.ops4j.pax.logging/pax-logging-service/1.8.4 = 8
>     Updated org.ops4j.pax.logging.cfg as follows:-
>     log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>     log4j.appender.stdout.layout=net.logstash.log4j.JSONEventLayoutV1
>     log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} | %-5.5p |
> %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} -
> %X{bundle.version} | %m%n
>
>
>  Thanks,
> Debraj
>
> On Mon, Feb 29, 2016 at 1:17 PM, Achim Nierbeck <[email protected]>
> wrote:
>
>> Depends on if you have an appender that can do so.
>> If you have such an appender, make sure to attach it to pax-logging.
>> One known to work solution is to have a fragment bundle which attaches to
>> the pax-logging service bundle (if it's a log4j 1.x bundle)
>>
>> regards, Achim
>>
>>
>> 2016-02-29 6:46 GMT+01:00 D <[email protected]>:
>>
>>> Is there a way we can make karaf log in JSON format?
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607.html
>>> Sent from the Karaf - User mailing list archive at Nabble.com.
>>>
>>
>>
>>
>> --
>>
>> Apache Member
>> Apache Karaf <http://karaf.apache.org/> Committer & PMC
>> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer
>> & Project Lead
>> blog <http://notizblog.nierbeck.de/>
>> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
>>
>> Software Architect / Project Manager / Scrum Master
>>
>>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Reply via email to