You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by D <su...@gmail.com> on 2016/02/29 06:46:07 UTC
Karaf logging in JSON format
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.
RE: Karaf logging in JSON format
Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
You may also export your JSON implementation as a PaxAppender service with the “org.ops4j.pax.logging.appender.name” property containing the desired identifier which will be used in the Log4J conf file.
JP
De : Achim Nierbeck [mailto:bcanhome@googlemail.com]
Envoyé : lundi 29 février 2016 08:48
À : user@karaf.apache.org
Objet : Re: Karaf logging in JSON format
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 <su...@gmail.com>>:
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
Re: Karaf logging in JSON format
Posted by D <su...@gmail.com>.
Hi Achim,
I followed the discussion here in PAXLOGGING-114
<https://ops4j1.jira.com/browse/PAXLOGGING-114> . I modified my pom.xml
<https://gist.github.com/debraj-manna/dbcf020f4532056a9802> . But still
no luck. Getting the same error. I am also attaching the bundle that is
getting created now.
114. I modified my pom.xml . But still no luck. Getting the same error. I
am also attaching the bundle that is getting created now. Output of
MANIFEST.MF
Manifest-Version: 1.0
Bnd-LastModified: 1456777423755
Build-Jdk: 1.8.0_66
Built-By: jabong
Bundle-Description: Log4j pattern layout that conforms to the logstash j
son_event format
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion: 2
Bundle-Name: net.logstash.log4j.jsonevent-layout
Bundle-SymbolicName: net.logstash.log4j.jsonevent-layout
Bundle-Version: 1.8.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Embed-Dependency: *;scope=compile|runtime;inline=true
Export-Package: net.logstash.log4j.data;version="1.8.0.SNAPSHOT",org.apa
che.log4j.jdbc;uses:="org.apache.log4j,org.apache.log4j.spi";version="1
.8.0.SNAPSHOT",org.apache.log4j.lf5.viewer.categoryexplorer;uses:="java
x.swing.table,javax.swing.tree,javax.swing.event,javax.swing,org.apache
.log4j.lf5";version="1.8.0.SNAPSHOT",org.apache.commons.lang.reflect;us
es:="org.apache.commons.lang";version="2.6",org.apache.commons.lang.mat
h;uses:="org.apache.commons.lang.text,org.apache.commons.lang";version=
"2.6",org.apache.log4j.net;uses:="org.apache.log4j,org.apache.log4j.spi
,org.apache.log4j.helpers,javax.jms,javax.naming,org.apache.log4j.xml,j
avax.mail,org.w3c.dom,javax.mail.internet,javax.jmdns";version="1.8.0.S
NAPSHOT",net.minidev.json.parser;uses:="net.minidev.json";version="1.8.
0.SNAPSHOT",org.apache.commons.lang.builder;uses:="org.apache.commons.l
ang,org.apache.commons.lang.math";version="2.6",org.apache.commons.lang
.time;uses:="org.apache.commons.lang,org.apache.commons.lang.text";vers
ion="2.6",org.apache.log4j.xml;uses:="org.w3c.dom,org.xml.sax,javax.xml
.parsers,org.apache.log4j.config,org.apache.log4j.helpers,org.apache.lo
g4j.or,org.apache.log4j,org.apache.log4j.spi";version="1.8.0.SNAPSHOT",
net.minidev.json;uses:="net.minidev.json.parser";version="1.8.0.SNAPSHO
T",org.apache.log4j.jmx;uses:="javax.management,org.apache.log4j,com.su
n.jdmk.comm,org.apache.log4j.helpers,org.apache.log4j.spi";version="1.8
.0.SNAPSHOT",org.apache.log4j.or;uses:="org.apache.log4j.helpers,org.ap
ache.log4j.spi,org.apache.log4j";version="1.8.0.SNAPSHOT",org.apache.lo
g4j.lf5.util;uses:="org.apache.log4j.lf5,org.apache.log4j.lf5.viewer,ja
vax.swing";version="1.8.0.SNAPSHOT",org.apache.commons.lang;uses:="org.
apache.commons.lang.builder,org.apache.commons.lang.math,org.apache.com
mons.lang.text,org.apache.commons.lang.exception,org.apache.commons.lan
g.reflect";version="2.6",org.apache.log4j.or.sax;uses:="org.apache.log4
j.or,org.xml.sax";version="1.8.0.SNAPSHOT",org.apache.commons.lang.muta
ble;uses:="org.apache.commons.lang,org.apache.commons.lang.math";versio
n="2.6",org.apache.log4j.config;uses:="org.apache.log4j.helpers,org.apa
che.log4j,org.apache.log4j.spi";version="1.8.0.SNAPSHOT",org.apache.log
4j.helpers;uses:="org.apache.log4j,org.apache.log4j.spi,org.apache.log4
j.pattern";version="1.8.0.SNAPSHOT",org.apache.log4j.chainsaw;uses:="or
g.apache.log4j,javax.swing,javax.swing.event,javax.swing.text,javax.swi
ng.border,org.apache.log4j.spi,org.xml.sax,javax.xml.parsers,javax.swin
g.table,org.xml.sax.helpers";version="1.8.0.SNAPSHOT",org.apache.log4j.
nt;uses:="org.apache.log4j.helpers,org.apache.log4j,org.apache.log4j.sp
i";version="1.8.0.SNAPSHOT",org.apache.log4j.lf5.viewer;uses:="javax.sw
ing.table,org.apache.log4j.lf5,javax.swing,org.apache.log4j.lf5.viewer.
categoryexplorer,javax.swing.text,org.apache.log4j.lf5.viewer.configure
,javax.swing.border,org.apache.log4j.lf5.util,javax.swing.event";versio
n="1.8.0.SNAPSHOT",org.apache.log4j.lf5.viewer.configure;uses:="org.w3c
.dom,org.apache.log4j.lf5.viewer.categoryexplorer,javax.swing.tree,org.
apache.log4j.lf5.viewer,javax.xml.parsers,org.apache.log4j.lf5,javax.sw
ing";version="1.8.0.SNAPSHOT",org.apache.log4j.lf5;uses:="org.apache.lo
g4j.lf5.viewer,org.apache.log4j,org.apache.log4j.spi";version="1.8.0.SN
APSHOT",org.apache.log4j.varia;uses:="org.apache.log4j.spi,org.apache.l
og4j,org.apache.log4j.helpers";version="1.8.0.SNAPSHOT",org.apache.comm
ons.lang.enums;uses:="org.apache.commons.lang";version="2.6",org.apache
.log4j.lf5.config;version="1.8.0.SNAPSHOT",org.apache.log4j.lf5.viewer.
images;version="1.8.0.SNAPSHOT",org.apache.commons.lang.exception;uses:
="org.apache.commons.lang";version="2.6",org.apache.commons.lang.text;u
ses:="org.apache.commons.lang";version="2.6",org.apache.log4j.pattern;u
ses:="org.apache.log4j.helpers,org.apache.log4j.spi,org.apache.log4j,or
g.apache.log4j.or";version="1.8.0.SNAPSHOT",net.logstash.log4j;uses:="n
et.logstash.log4j.data,org.apache.commons.lang.time,net.minidev.json,or
g.apache.commons.lang,org.apache.log4j,org.apache.log4j.spi,org.apache.
log4j.helpers";version="1.8.0.SNAPSHOT",org.apache.commons.lang.enum;us
es:="org.apache.commons.lang";version="2.6",org.apache.log4j.or.jms;use
s:="org.apache.log4j.helpers,javax.jms,org.apache.log4j.or";version="1.
8.0.SNAPSHOT",org.apache.log4j;uses:="org.apache.log4j.spi,org.apache.l
og4j.helpers,org.apache.log4j.pattern,org.apache.log4j.or,org.apache.lo
g4j.config";version="1.8.0.SNAPSHOT",org.apache.log4j.spi;uses:="org.ap
ache.log4j,com.ibm.uvm.tools,org.apache.log4j.helpers,org.apache.log4j.
or";version="1.8.0.SNAPSHOT"
Fragment-Host: org.ops4j.pax.logging.pax-logging-service;bundle-version=
"[1.6,1.9)"
Implementation-Version: 1.8-SNAPSHOT
Import-Package: com.ibm.uvm.tools,com.sun.jdmk.comm,javax.jmdns,javax.jm
s,javax.mail,javax.mail.internet,javax.management,javax.naming,javax.sw
ing,javax.swing.border,javax.swing.event,javax.swing.table,javax.swing.
text,javax.swing.tree,javax.xml.parsers,org.w3c.dom,org.xml.sax,org.xml
.sax.helpers
Tool: Bnd-1.50.0
karaf@root>list -t 0
START LEVEL 100 , List Threshold: 0
ID | State | Lvl | Version | Name
-------------------------------------------------------------------------------------------------------------------------------
0 | Active | 0 | 4.2.1 | System Bundle
1 | Active | 5 | 2.4.1 | OPS4J Pax Url -
aether:
2 | Active | 5 | 2.4.1 | OPS4J Pax Url -
wrap:
3 | Active | 8 | 1.8.4 | OPS4J Pax
Logging - API
4 | Active | 8 | 1.8.4 | OPS4J Pax
Logging - Service
5 | Active | 10 | 3.0.5 | Apache Karaf ::
Service :: Guard
--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045640.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Karaf logging in JSON format
Posted by D <su...@gmail.com>.
I am a new to Karaf. This is what I have done. In one of my bundles I have
added this as a dependency
<dependency>
<groupId>net.logstash.log4j</groupId>
<artifactId>jsonevent-layout</artifactId>
<version>1.7</version>
</dependency>
Then exported net.logstash.log4j from that bundle & deployed that bundle in
Karaf.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Description>${project.description}</Bundle-Description>
<Import-Package>*;resolution:=optional</Import-Package>
<Export-Package>net.logstash.log4j</Export-Package>
</instructions>
</configuration>
</plugin>
But still getting same error.
On Mon, Feb 29, 2016 at 4:38 PM, Achim Nierbeck [via Karaf] <
ml-node+s922171n4045620h45@n3.nabble.com> wrote:
> But your bundle needs to contain that package, if it doesn't it's of no
> help
> Did you try to embed those classes in your own bundle?
>
> regards, Achim
>
>
> 2016-02-29 12:01 GMT+01:00 D <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4045620&i=0>>:
>
>> No. But I want to expose it to all other osgi bundles in the containers.
>> So
>> I also added <Export-Package>*</Export-Package> in the pom.xml. But still
>> getting the error Could not instantiate class
>> [net.logstash.log4j.JSONEventLayoutV1].
>>
>>
>> On Mon, Feb 29, 2016 at 4:21 PM, Achim Nierbeck [via Karaf] <
>> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4045620&i=1>>
>> wrote:
>>
>> > Do you have a bundle in your container, which actually also exports that
>> > package/class?
>> >
>> > regards, Achim
>> >
>> > 2016-02-29 11:47 GMT+01:00 D <[hidden email]
>> > <http:///user/SendEmail.jtp?type=node&node=4045618&i=0>>:
>>
>> >
>> >> Hi,
>> >>
>> >> I set <Import-Package>*;resolution:=optional</Import-Package> but still
>> >> getting the exception Could not instantiate class
>> >> [net.logstash.log4j.JSONEventLayoutV1].
>> >>
>> >> My entire pom.xml looks like below:-
>> >>
>> >> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
>> >> http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
>> >> http://maven.apache.org/POM/4.0.0
>> >> http://maven.apache.org/maven-v4_0_0.xsd">
>> >> <modelVersion>4.0.0</modelVersion>
>> >> <groupId>net.logstash.log4j</groupId>
>> >> <artifactId>jsonevent-layout</artifactId>
>> >> <packaging>jar</packaging>
>> >> <version>1.8-SNAPSHOT</version>
>> >> <name>jsonevent-layout</name>
>> >> <description>Log4j pattern layout that conforms to the logstash
>> >> json_event format</description>
>> >> <url>http://logstash.net</url>
>> >> <licenses>
>> >> <license>
>> >> <name>The Apache Software License, Version 2.0</name>
>> >> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
>> >> <distribution>repo</distribution>
>> >> </license>
>> >> </licenses>
>> >> <developers>
>> >> <developer>
>> >> <id>lusis</id>
>> >> <name>John E. Vincent</name>
>> >> <email>lusis.org+[hidden email]
>> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=1></email>
>> >> </developer>
>> >> <developer>
>> >> <id>pyr</id>
>> >> <name>Pierre-Yves Ritschard</name>
>> >> <email>[hidden email]
>> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=2></email>
>> >> </developer>
>> >> </developers>
>> >> <properties>
>> >>
>> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>> >>
>> >>
>> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
>> >> </properties>
>> >> <parent>
>> >> <groupId>org.sonatype.oss</groupId>
>> >> <artifactId>oss-parent</artifactId>
>> >> <version>7</version>
>> >> </parent>
>> >> <scm>
>> >> <connection>scm:git:[hidden email]
>> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=3>:g[hidden
>> email]
>> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=4>:
>> >> logstash/log4j-jsonevent-layout.git</connection>
>> >> <developerConnection>[hidden email]
>> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=5>:
>> >> logstash/log4j-jsonevent-layout.git</developerConnection>
>> >> <url>[hidden email]
>> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=6>
>>
>> >> :logstash/log4j-jsonevent-layout.git</url>
>> >>
>> >> </scm>
>> >> <build>
>> >> <pluginManagement>
>> >> <plugins>
>> >> <plugin>
>> >> <artifactId>maven-assembly-plugin</artifactId>
>> >> <version>2.2.2</version>
>> >> <executions>
>> >> <execution>
>> >> <id>uberjar</id>
>> >> <phase>package</phase>
>> >> <goals>
>> >> <goal>single</goal>
>> >> </goals>
>> >> </execution>
>> >> </executions>
>> >> <configuration>
>> >> <descriptorRefs>
>> >> <descriptorRef>jar-with-dependencies</descriptorRef>
>> >> </descriptorRefs>
>> >> </configuration>
>> >> </plugin>
>> >> <plugin>
>> >> <groupId>org.apache.maven.plugins</groupId>
>> >> <artifactId>maven-compiler-plugin</artifactId>
>> >> <version>2.3.2</version>
>> >> <configuration>
>> >> <source>1.5</source>
>> >> <target>1.5</target>
>> >> </configuration>
>> >> </plugin>
>> >> <plugin>
>> >> <groupId>org.apache.maven.plugins</groupId>
>> >> <artifactId>maven-source-plugin</artifactId>
>> >> <executions>
>> >> <execution>
>> >> <id>attach-sources</id>
>> >> <goals>
>> >> <goal>jar</goal>
>> >> </goals>
>> >> </execution>
>> >> </executions>
>> >> </plugin>
>> >> <plugin>
>> >> <groupId>org.apache.maven.plugins</groupId>
>> >> <artifactId>maven-javadoc-plugin</artifactId>
>> >> <executions>
>> >> <execution>
>> >> <id>attach-javadocs</id>
>> >> <goals>
>> >> <goal>jar</goal>
>> >> </goals>
>> >> </execution>
>> >> </executions>
>> >> </plugin>
>> >> </plugins>
>> >> </pluginManagement>
>> >> </build>
>> >> <dependencies>
>> >> <dependency>
>> >> <groupId>net.minidev</groupId>
>> >> <artifactId>json-smart</artifactId>
>> >> <version>1.1.1</version>
>> >> </dependency>
>> >> <dependency>
>> >> <groupId>log4j</groupId>
>> >> <artifactId>log4j</artifactId>
>> >> <version>1.2.16</version>
>> >> <scope>provided</scope>
>> >> </dependency>
>> >> <dependency>
>> >> <groupId>commons-lang</groupId>
>> >> <artifactId>commons-lang</artifactId>
>> >> <version>2.6</version>
>> >> </dependency>
>> >> <dependency>
>> >> <groupId>junit</groupId>
>> >> <artifactId>junit</artifactId>
>> >> <version>4.8.1</version>
>> >> <scope>test</scope>
>> >> </dependency>
>> >> </dependencies>
>> >> <profiles>
>> >> <profile>
>> >> <id>bundle</id>
>> >> <build>
>> >> <plugins>
>> >> <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>*;resolution:=optional</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>
>> >> </plugins>
>> >> </build>
>> >> </profile>
>> >> <profile>
>> >> <id>release-sign-artifacts</id>
>> >> <activation>
>> >> <property>
>> >> <name>performRelease</name>
>> >> <value>true</value>
>> >> </property>
>> >> </activation>
>> >> <build>
>> >> <plugins>
>> >> <plugin>
>> >> <groupId>org.apache.maven.plugins</groupId>
>> >> <artifactId>maven-gpg-plugin</artifactId>
>> >> <executions>
>> >> <execution>
>> >> <id>sign-artifacts</id>
>> >> <phase>verify</phase>
>> >> <goals>
>> >> <goal>sign</goal>
>> >> </goals>
>> >> </execution>
>> >> </executions>
>> >> </plugin>
>> >> <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>*;resolution:=optional</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>
>> >> </plugins>
>> >> </build>
>> >> </profile>
>> >> </profiles>
>> >> <distributionManagement>
>> >> <snapshotRepository>
>> >> <id>ossrh</id>
>> >> <url>https://oss.sonatype.org/content/repositories/snapshots</url>
>> >> </snapshotRepository>
>> >> <repository>
>> >> <id>ossrh</id>
>> >> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/
>> >> </url>
>> >> </repository>
>> >> </distributionManagement>
>> >> </project>
>> >>
>> >>
>> >>
>> >> On Mon, Feb 29, 2016 at 3:50 PM, Achim Nierbeck [via Karaf] <
>> >> [hidden email] <http://
>> /user/SendEmail.jtp?type=node&node=4045618&i=7>>
>>
>> >> wrote:
>> >>
>> >> > 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 <[hidden email]
>> >> > <http:///user/SendEmail.jtp?type=node&node=4045613&i=0>>:
>> >> >
>> >> >> 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 <[hidden email]
>> >> >> <http:///user/SendEmail.jtp?type=node&node=4045613&i=1>> 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 <[hidden email]
>> >> >>> <http:///user/SendEmail.jtp?type=node&node=4045613&i=2>>:
>> >> >>>
>> >> >>>> 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
>> >> >
>> >> >
>> >> >
>> >> > ------------------------------
>> >> > If you reply to this email, your message will be added to the
>> discussion
>> >> > below:
>> >> >
>> >> >
>> >>
>> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045613.html
>> >> > To unsubscribe from Karaf logging in JSON format, click here
>> >> > < > .
>> >> > NAML
>> >> > <
>> >>
>> http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045617.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
>> >
>> >
>> >
>> > ------------------------------
>> > If you reply to this email, your message will be added to the discussion
>> > below:
>> >
>> >
>> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045618.html
>> > To unsubscribe from Karaf logging in JSON format, click here
>> > < > .
>> > NAML
>> > <
>> http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>> >
>> >
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045619.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
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045620.html
> To unsubscribe from Karaf logging in JSON format, click here
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4045607&code=c3ViaGFyYWoubWFubmFAZ21haWwuY29tfDQwNDU2MDd8MTIyMTY4MjkyMg==>
> .
> NAML
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045621.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Karaf logging in JSON format
Posted by Achim Nierbeck <bc...@googlemail.com>.
But your bundle needs to contain that package, if it doesn't it's of no help
Did you try to embed those classes in your own bundle?
regards, Achim
2016-02-29 12:01 GMT+01:00 D <su...@gmail.com>:
> No. But I want to expose it to all other osgi bundles in the containers. So
> I also added <Export-Package>*</Export-Package> in the pom.xml. But still
> getting the error Could not instantiate class
> [net.logstash.log4j.JSONEventLayoutV1].
>
>
> On Mon, Feb 29, 2016 at 4:21 PM, Achim Nierbeck [via Karaf] <
> ml-node+s922171n4045618h83@n3.nabble.com> wrote:
>
> > Do you have a bundle in your container, which actually also exports that
> > package/class?
> >
> > regards, Achim
> >
> > 2016-02-29 11:47 GMT+01:00 D <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4045618&i=0>>:
> >
> >> Hi,
> >>
> >> I set <Import-Package>*;resolution:=optional</Import-Package> but still
> >> getting the exception Could not instantiate class
> >> [net.logstash.log4j.JSONEventLayoutV1].
> >>
> >> My entire pom.xml looks like below:-
> >>
> >> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> >> http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> >> http://maven.apache.org/POM/4.0.0
> >> http://maven.apache.org/maven-v4_0_0.xsd">
> >> <modelVersion>4.0.0</modelVersion>
> >> <groupId>net.logstash.log4j</groupId>
> >> <artifactId>jsonevent-layout</artifactId>
> >> <packaging>jar</packaging>
> >> <version>1.8-SNAPSHOT</version>
> >> <name>jsonevent-layout</name>
> >> <description>Log4j pattern layout that conforms to the logstash
> >> json_event format</description>
> >> <url>http://logstash.net</url>
> >> <licenses>
> >> <license>
> >> <name>The Apache Software License, Version 2.0</name>
> >> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
> >> <distribution>repo</distribution>
> >> </license>
> >> </licenses>
> >> <developers>
> >> <developer>
> >> <id>lusis</id>
> >> <name>John E. Vincent</name>
> >> <email>lusis.org+[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=1></email>
> >> </developer>
> >> <developer>
> >> <id>pyr</id>
> >> <name>Pierre-Yves Ritschard</name>
> >> <email>[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=2></email>
> >> </developer>
> >> </developers>
> >> <properties>
> >> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> >>
> >>
> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
> >> </properties>
> >> <parent>
> >> <groupId>org.sonatype.oss</groupId>
> >> <artifactId>oss-parent</artifactId>
> >> <version>7</version>
> >> </parent>
> >> <scm>
> >> <connection>scm:git:[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=3>:g[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=4>:
> >> logstash/log4j-jsonevent-layout.git</connection>
> >> <developerConnection>[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=5>:
> >> logstash/log4j-jsonevent-layout.git</developerConnection>
> >> <url>[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=4045618&i=6>
> >> :logstash/log4j-jsonevent-layout.git</url>
> >>
> >> </scm>
> >> <build>
> >> <pluginManagement>
> >> <plugins>
> >> <plugin>
> >> <artifactId>maven-assembly-plugin</artifactId>
> >> <version>2.2.2</version>
> >> <executions>
> >> <execution>
> >> <id>uberjar</id>
> >> <phase>package</phase>
> >> <goals>
> >> <goal>single</goal>
> >> </goals>
> >> </execution>
> >> </executions>
> >> <configuration>
> >> <descriptorRefs>
> >> <descriptorRef>jar-with-dependencies</descriptorRef>
> >> </descriptorRefs>
> >> </configuration>
> >> </plugin>
> >> <plugin>
> >> <groupId>org.apache.maven.plugins</groupId>
> >> <artifactId>maven-compiler-plugin</artifactId>
> >> <version>2.3.2</version>
> >> <configuration>
> >> <source>1.5</source>
> >> <target>1.5</target>
> >> </configuration>
> >> </plugin>
> >> <plugin>
> >> <groupId>org.apache.maven.plugins</groupId>
> >> <artifactId>maven-source-plugin</artifactId>
> >> <executions>
> >> <execution>
> >> <id>attach-sources</id>
> >> <goals>
> >> <goal>jar</goal>
> >> </goals>
> >> </execution>
> >> </executions>
> >> </plugin>
> >> <plugin>
> >> <groupId>org.apache.maven.plugins</groupId>
> >> <artifactId>maven-javadoc-plugin</artifactId>
> >> <executions>
> >> <execution>
> >> <id>attach-javadocs</id>
> >> <goals>
> >> <goal>jar</goal>
> >> </goals>
> >> </execution>
> >> </executions>
> >> </plugin>
> >> </plugins>
> >> </pluginManagement>
> >> </build>
> >> <dependencies>
> >> <dependency>
> >> <groupId>net.minidev</groupId>
> >> <artifactId>json-smart</artifactId>
> >> <version>1.1.1</version>
> >> </dependency>
> >> <dependency>
> >> <groupId>log4j</groupId>
> >> <artifactId>log4j</artifactId>
> >> <version>1.2.16</version>
> >> <scope>provided</scope>
> >> </dependency>
> >> <dependency>
> >> <groupId>commons-lang</groupId>
> >> <artifactId>commons-lang</artifactId>
> >> <version>2.6</version>
> >> </dependency>
> >> <dependency>
> >> <groupId>junit</groupId>
> >> <artifactId>junit</artifactId>
> >> <version>4.8.1</version>
> >> <scope>test</scope>
> >> </dependency>
> >> </dependencies>
> >> <profiles>
> >> <profile>
> >> <id>bundle</id>
> >> <build>
> >> <plugins>
> >> <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>*;resolution:=optional</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>
> >> </plugins>
> >> </build>
> >> </profile>
> >> <profile>
> >> <id>release-sign-artifacts</id>
> >> <activation>
> >> <property>
> >> <name>performRelease</name>
> >> <value>true</value>
> >> </property>
> >> </activation>
> >> <build>
> >> <plugins>
> >> <plugin>
> >> <groupId>org.apache.maven.plugins</groupId>
> >> <artifactId>maven-gpg-plugin</artifactId>
> >> <executions>
> >> <execution>
> >> <id>sign-artifacts</id>
> >> <phase>verify</phase>
> >> <goals>
> >> <goal>sign</goal>
> >> </goals>
> >> </execution>
> >> </executions>
> >> </plugin>
> >> <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>*;resolution:=optional</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>
> >> </plugins>
> >> </build>
> >> </profile>
> >> </profiles>
> >> <distributionManagement>
> >> <snapshotRepository>
> >> <id>ossrh</id>
> >> <url>https://oss.sonatype.org/content/repositories/snapshots</url>
> >> </snapshotRepository>
> >> <repository>
> >> <id>ossrh</id>
> >> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/
> >> </url>
> >> </repository>
> >> </distributionManagement>
> >> </project>
> >>
> >>
> >>
> >> On Mon, Feb 29, 2016 at 3:50 PM, Achim Nierbeck [via Karaf] <
> >> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4045618&i=7>>
> >> wrote:
> >>
> >> > 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 <[hidden email]
> >> > <http:///user/SendEmail.jtp?type=node&node=4045613&i=0>>:
> >> >
> >> >> 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 <[hidden email]
> >> >> <http:///user/SendEmail.jtp?type=node&node=4045613&i=1>> 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 <[hidden email]
> >> >>> <http:///user/SendEmail.jtp?type=node&node=4045613&i=2>>:
> >> >>>
> >> >>>> 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
> >> >
> >> >
> >> >
> >> > ------------------------------
> >> > If you reply to this email, your message will be added to the
> discussion
> >> > below:
> >> >
> >> >
> >>
> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045613.html
> >> > To unsubscribe from Karaf logging in JSON format, click here
> >> > < > .
> >> > NAML
> >> > <
> >>
> http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >> >
> >> >
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045617.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
> >
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045618.html
> > To unsubscribe from Karaf logging in JSON format, click here
> > <
> http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4045607&code=c3ViaGFyYWoubWFubmFAZ21haWwuY29tfDQwNDU2MDd8MTIyMTY4MjkyMg==
> >
> > .
> > NAML
> > <
> http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045619.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
Re: Karaf logging in JSON format
Posted by D <su...@gmail.com>.
No. But I want to expose it to all other osgi bundles in the containers. So
I also added <Export-Package>*</Export-Package> in the pom.xml. But still
getting the error Could not instantiate class
[net.logstash.log4j.JSONEventLayoutV1].
On Mon, Feb 29, 2016 at 4:21 PM, Achim Nierbeck [via Karaf] <
ml-node+s922171n4045618h83@n3.nabble.com> wrote:
> Do you have a bundle in your container, which actually also exports that
> package/class?
>
> regards, Achim
>
> 2016-02-29 11:47 GMT+01:00 D <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4045618&i=0>>:
>
>> Hi,
>>
>> I set <Import-Package>*;resolution:=optional</Import-Package> but still
>> getting the exception Could not instantiate class
>> [net.logstash.log4j.JSONEventLayoutV1].
>>
>> My entire pom.xml looks like below:-
>>
>> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
>> http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
>> http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>> <modelVersion>4.0.0</modelVersion>
>> <groupId>net.logstash.log4j</groupId>
>> <artifactId>jsonevent-layout</artifactId>
>> <packaging>jar</packaging>
>> <version>1.8-SNAPSHOT</version>
>> <name>jsonevent-layout</name>
>> <description>Log4j pattern layout that conforms to the logstash
>> json_event format</description>
>> <url>http://logstash.net</url>
>> <licenses>
>> <license>
>> <name>The Apache Software License, Version 2.0</name>
>> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
>> <distribution>repo</distribution>
>> </license>
>> </licenses>
>> <developers>
>> <developer>
>> <id>lusis</id>
>> <name>John E. Vincent</name>
>> <email>lusis.org+[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=1></email>
>> </developer>
>> <developer>
>> <id>pyr</id>
>> <name>Pierre-Yves Ritschard</name>
>> <email>[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=2></email>
>> </developer>
>> </developers>
>> <properties>
>> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>
>> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
>> </properties>
>> <parent>
>> <groupId>org.sonatype.oss</groupId>
>> <artifactId>oss-parent</artifactId>
>> <version>7</version>
>> </parent>
>> <scm>
>> <connection>scm:git:[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=3>:g[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=4>:
>> logstash/log4j-jsonevent-layout.git</connection>
>> <developerConnection>[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=5>:
>> logstash/log4j-jsonevent-layout.git</developerConnection>
>> <url>[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045618&i=6>
>> :logstash/log4j-jsonevent-layout.git</url>
>>
>> </scm>
>> <build>
>> <pluginManagement>
>> <plugins>
>> <plugin>
>> <artifactId>maven-assembly-plugin</artifactId>
>> <version>2.2.2</version>
>> <executions>
>> <execution>
>> <id>uberjar</id>
>> <phase>package</phase>
>> <goals>
>> <goal>single</goal>
>> </goals>
>> </execution>
>> </executions>
>> <configuration>
>> <descriptorRefs>
>> <descriptorRef>jar-with-dependencies</descriptorRef>
>> </descriptorRefs>
>> </configuration>
>> </plugin>
>> <plugin>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-compiler-plugin</artifactId>
>> <version>2.3.2</version>
>> <configuration>
>> <source>1.5</source>
>> <target>1.5</target>
>> </configuration>
>> </plugin>
>> <plugin>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-source-plugin</artifactId>
>> <executions>
>> <execution>
>> <id>attach-sources</id>
>> <goals>
>> <goal>jar</goal>
>> </goals>
>> </execution>
>> </executions>
>> </plugin>
>> <plugin>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-javadoc-plugin</artifactId>
>> <executions>
>> <execution>
>> <id>attach-javadocs</id>
>> <goals>
>> <goal>jar</goal>
>> </goals>
>> </execution>
>> </executions>
>> </plugin>
>> </plugins>
>> </pluginManagement>
>> </build>
>> <dependencies>
>> <dependency>
>> <groupId>net.minidev</groupId>
>> <artifactId>json-smart</artifactId>
>> <version>1.1.1</version>
>> </dependency>
>> <dependency>
>> <groupId>log4j</groupId>
>> <artifactId>log4j</artifactId>
>> <version>1.2.16</version>
>> <scope>provided</scope>
>> </dependency>
>> <dependency>
>> <groupId>commons-lang</groupId>
>> <artifactId>commons-lang</artifactId>
>> <version>2.6</version>
>> </dependency>
>> <dependency>
>> <groupId>junit</groupId>
>> <artifactId>junit</artifactId>
>> <version>4.8.1</version>
>> <scope>test</scope>
>> </dependency>
>> </dependencies>
>> <profiles>
>> <profile>
>> <id>bundle</id>
>> <build>
>> <plugins>
>> <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>*;resolution:=optional</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>
>> </plugins>
>> </build>
>> </profile>
>> <profile>
>> <id>release-sign-artifacts</id>
>> <activation>
>> <property>
>> <name>performRelease</name>
>> <value>true</value>
>> </property>
>> </activation>
>> <build>
>> <plugins>
>> <plugin>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-gpg-plugin</artifactId>
>> <executions>
>> <execution>
>> <id>sign-artifacts</id>
>> <phase>verify</phase>
>> <goals>
>> <goal>sign</goal>
>> </goals>
>> </execution>
>> </executions>
>> </plugin>
>> <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>*;resolution:=optional</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>
>> </plugins>
>> </build>
>> </profile>
>> </profiles>
>> <distributionManagement>
>> <snapshotRepository>
>> <id>ossrh</id>
>> <url>https://oss.sonatype.org/content/repositories/snapshots</url>
>> </snapshotRepository>
>> <repository>
>> <id>ossrh</id>
>> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/
>> </url>
>> </repository>
>> </distributionManagement>
>> </project>
>>
>>
>>
>> On Mon, Feb 29, 2016 at 3:50 PM, Achim Nierbeck [via Karaf] <
>> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4045618&i=7>>
>> wrote:
>>
>> > 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 <[hidden email]
>> > <http:///user/SendEmail.jtp?type=node&node=4045613&i=0>>:
>> >
>> >> 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 <[hidden email]
>> >> <http:///user/SendEmail.jtp?type=node&node=4045613&i=1>> 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 <[hidden email]
>> >>> <http:///user/SendEmail.jtp?type=node&node=4045613&i=2>>:
>> >>>
>> >>>> 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
>> >
>> >
>> >
>> > ------------------------------
>> > If you reply to this email, your message will be added to the discussion
>> > below:
>> >
>> >
>> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045613.html
>> > To unsubscribe from Karaf logging in JSON format, click here
>> > < > .
>> > NAML
>> > <
>> http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>> >
>> >
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045617.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
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045618.html
> To unsubscribe from Karaf logging in JSON format, click here
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4045607&code=c3ViaGFyYWoubWFubmFAZ21haWwuY29tfDQwNDU2MDd8MTIyMTY4MjkyMg==>
> .
> NAML
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045619.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Karaf logging in JSON format
Posted by Achim Nierbeck <bc...@googlemail.com>.
Do you have a bundle in your container, which actually also exports that
package/class?
regards, Achim
2016-02-29 11:47 GMT+01:00 D <su...@gmail.com>:
> Hi,
>
> I set <Import-Package>*;resolution:=optional</Import-Package> but still
> getting the exception Could not instantiate class
> [net.logstash.log4j.JSONEventLayoutV1].
>
> My entire pom.xml looks like below:-
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd
> ">
> <modelVersion>4.0.0</modelVersion>
> <groupId>net.logstash.log4j</groupId>
> <artifactId>jsonevent-layout</artifactId>
> <packaging>jar</packaging>
> <version>1.8-SNAPSHOT</version>
> <name>jsonevent-layout</name>
> <description>Log4j pattern layout that conforms to the logstash
> json_event format</description>
> <url>http://logstash.net</url>
> <licenses>
> <license>
> <name>The Apache Software License, Version 2.0</name>
> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
> <distribution>repo</distribution>
> </license>
> </licenses>
> <developers>
> <developer>
> <id>lusis</id>
> <name>John E. Vincent</name>
> <email>lusis.org+github.com@gmail.com</email>
> </developer>
> <developer>
> <id>pyr</id>
> <name>Pierre-Yves Ritschard</name>
> <email>pyr@spootnik.org</email>
> </developer>
> </developers>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>
> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
> </properties>
> <parent>
> <groupId>org.sonatype.oss</groupId>
> <artifactId>oss-parent</artifactId>
> <version>7</version>
> </parent>
> <scm>
> <connection>scm:git:git@github.com:git@github.com:
> logstash/log4j-jsonevent-layout.git</connection>
> <developerConnection>scm:git:git@github.com:
> logstash/log4j-jsonevent-layout.git</developerConnection>
> <url>git@github.com:logstash/log4j-jsonevent-layout.git</url>
> </scm>
> <build>
> <pluginManagement>
> <plugins>
> <plugin>
> <artifactId>maven-assembly-plugin</artifactId>
> <version>2.2.2</version>
> <executions>
> <execution>
> <id>uberjar</id>
> <phase>package</phase>
> <goals>
> <goal>single</goal>
> </goals>
> </execution>
> </executions>
> <configuration>
> <descriptorRefs>
> <descriptorRef>jar-with-dependencies</descriptorRef>
> </descriptorRefs>
> </configuration>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>2.3.2</version>
> <configuration>
> <source>1.5</source>
> <target>1.5</target>
> </configuration>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-source-plugin</artifactId>
> <executions>
> <execution>
> <id>attach-sources</id>
> <goals>
> <goal>jar</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-javadoc-plugin</artifactId>
> <executions>
> <execution>
> <id>attach-javadocs</id>
> <goals>
> <goal>jar</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </pluginManagement>
> </build>
> <dependencies>
> <dependency>
> <groupId>net.minidev</groupId>
> <artifactId>json-smart</artifactId>
> <version>1.1.1</version>
> </dependency>
> <dependency>
> <groupId>log4j</groupId>
> <artifactId>log4j</artifactId>
> <version>1.2.16</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>commons-lang</groupId>
> <artifactId>commons-lang</artifactId>
> <version>2.6</version>
> </dependency>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>4.8.1</version>
> <scope>test</scope>
> </dependency>
> </dependencies>
> <profiles>
> <profile>
> <id>bundle</id>
> <build>
> <plugins>
> <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>*;resolution:=optional</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>
> </plugins>
> </build>
> </profile>
> <profile>
> <id>release-sign-artifacts</id>
> <activation>
> <property>
> <name>performRelease</name>
> <value>true</value>
> </property>
> </activation>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-gpg-plugin</artifactId>
> <executions>
> <execution>
> <id>sign-artifacts</id>
> <phase>verify</phase>
> <goals>
> <goal>sign</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <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>*;resolution:=optional</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>
> </plugins>
> </build>
> </profile>
> </profiles>
> <distributionManagement>
> <snapshotRepository>
> <id>ossrh</id>
> <url>https://oss.sonatype.org/content/repositories/snapshots</url>
> </snapshotRepository>
> <repository>
> <id>ossrh</id>
> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/
> </url>
> </repository>
> </distributionManagement>
> </project>
>
>
>
> On Mon, Feb 29, 2016 at 3:50 PM, Achim Nierbeck [via Karaf] <
> ml-node+s922171n4045613h28@n3.nabble.com> wrote:
>
> > 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 <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=4045613&i=0>>:
> >
> >> 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 <[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=4045613&i=1>> 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 <[hidden email]
> >>> <http:///user/SendEmail.jtp?type=node&node=4045613&i=2>>:
> >>>
> >>>> 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
> >
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045613.html
> > To unsubscribe from Karaf logging in JSON format, click here
> > <
> http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4045607&code=c3ViaGFyYWoubWFubmFAZ21haWwuY29tfDQwNDU2MDd8MTIyMTY4MjkyMg==
> >
> > .
> > NAML
> > <
> http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045617.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
Re: Karaf logging in JSON format
Posted by D <su...@gmail.com>.
Hi,
I set <Import-Package>*;resolution:=optional</Import-Package> but still
getting the exception Could not instantiate class
[net.logstash.log4j.JSONEventLayoutV1].
My entire pom.xml looks like below:-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.logstash.log4j</groupId>
<artifactId>jsonevent-layout</artifactId>
<packaging>jar</packaging>
<version>1.8-SNAPSHOT</version>
<name>jsonevent-layout</name>
<description>Log4j pattern layout that conforms to the logstash
json_event format</description>
<url>http://logstash.net</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>lusis</id>
<name>John E. Vincent</name>
<email>lusis.org+github.com@gmail.com</email>
</developer>
<developer>
<id>pyr</id>
<name>Pierre-Yves Ritschard</name>
<email>pyr@spootnik.org</email>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<scm>
<connection>scm:git:git@github.com:git@github.com:
logstash/log4j-jsonevent-layout.git</connection>
<developerConnection>scm:git:git@github.com:
logstash/log4j-jsonevent-layout.git</developerConnection>
<url>git@github.com:logstash/log4j-jsonevent-layout.git</url>
</scm>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.2</version>
<executions>
<execution>
<id>uberjar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>bundle</id>
<build>
<plugins>
<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>*;resolution:=optional</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>
</plugins>
</build>
</profile>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<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>*;resolution:=optional</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>
</plugins>
</build>
</profile>
</profiles>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>
On Mon, Feb 29, 2016 at 3:50 PM, Achim Nierbeck [via Karaf] <
ml-node+s922171n4045613h28@n3.nabble.com> wrote:
> 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 <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4045613&i=0>>:
>
>> 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 <[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4045613&i=1>> 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 <[hidden email]
>>> <http:///user/SendEmail.jtp?type=node&node=4045613&i=2>>:
>>>
>>>> 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
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045613.html
> To unsubscribe from Karaf logging in JSON format, click here
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4045607&code=c3ViaGFyYWoubWFubmFAZ21haWwuY29tfDQwNDU2MDd8MTIyMTY4MjkyMg==>
> .
> NAML
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-logging-in-JSON-format-tp4045607p4045617.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Karaf logging in JSON format
Posted by Achim Nierbeck <bc...@googlemail.com>.
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 <su...@gmail.com>:
> 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 <bc...@googlemail.com>
> 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 <su...@gmail.com>:
>>
>>> 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
Re: Karaf logging in JSON format
Posted by Debraj Manna <su...@gmail.com>.
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 <bc...@googlemail.com>
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 <su...@gmail.com>:
>
>> 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
>
>
Re: Karaf logging in JSON format
Posted by Achim Nierbeck <bc...@googlemail.com>.
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 <su...@gmail.com>:
> 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