Error while installing log4j2 api on Karaf

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Error while installing log4j2 api on Karaf

Prithviraj
Hi ,

We are using Karaf 3.2. We are using log4j2 , build 2.1 for logging .
While installing log4j2 bundles we are getting below error

installing log4j-api :-
bundle:install -s mvn:org.apache.logging.log4j/log4j-api/2.1

Exception :-

ERROR: Bundle org.apache.logging.log4j.api [272] EventDispatcher: Error during dispatch. (java.lang.IllegalMonitorStateException)
Bundle ID: 273
java.lang.IllegalMonitorStateException

installing
bundle:install -s mvn:org.apache.logging.log4j/log4j-core/2.1

Exception :-

ERROR: Bundle org.apache.logging.log4j.api [272] EventDispatcher: Error during dispatch. (java.lang.IllegalMonitorStateException)
Bundle ID: 274

Reply | Threaded
Open this post in threaded view
|

Re: Error while installing log4j2 api on Karaf

jbonofre
Hi,

Can you check if pax-logging-api doesn't already provide the log4j2 api ?

Regards
JB

On 03/09/2015 11:41 AM, Prithviraj wrote:

> Hi ,
>
> We are using Karaf 3.2. We are using log4j2 , build 2.1 for logging .
> While installing log4j2 bundles we are getting below error
>
> installing log4j-api :-
> bundle:install -s mvn:org.apache.logging.log4j/log4j-api/2.1
>
> Exception :-
>
> ERROR: Bundle org.apache.logging.log4j.api [272] EventDispatcher: Error
> during dispatch. (java.lang.IllegalMonitorStateException)
> Bundle ID: 273
> java.lang.IllegalMonitorStateException
>
> installing
> bundle:install -s mvn:org.apache.logging.log4j/log4j-core/2.1
>
> Exception :-
>
> ERROR: Bundle org.apache.logging.log4j.api [272] EventDispatcher: Error
> during dispatch. (java.lang.IllegalMonitorStateException)
> Bundle ID: 274
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Error-while-installing-log4j2-api-on-Karaf-tp4038875.html
> Sent from the Karaf - Dev mailing list archive at Nabble.com.
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Error while installing log4j2 api on Karaf

Prithviraj
Hi,

I checked pax package present in  local repository , but does not contain pax-logging-api  also not log4j2 api
It contains  only master, swissbox, url and web bundles
Reply | Threaded
Open this post in threaded view
|

Re: Error while installing log4j2 api on Karaf

Bernhard Schuhmann
This post was updated on .
Hi,

in case you haven't figured it out in the meantime yourself - Pax Logging has a separate implementation for the logging service that uses Log4j v2 instead of v1. The implementation is in another bundle pax-logging-log4j2, the implementation that uses v1 is pax-logging-service. pax-logging-log4j2 re-exports the log4j2 packages, no need to install the log4j2 bundle separately.

To get log4j2 working in Karaf, I've changed the Pax logging service bundle in etc/startup.properties:

#org/ops4j/pax/logging/pax-logging-service/1.8.1/pax-logging-service-1.8.1.jar = 8
org/ops4j/pax/logging/pax-logging-log4j2/1.8.1/pax-logging-log4j2-1.8.1.jar = 8
The log4j2 service implementation uses the same Config Admin pid, instead of log4j v1 settings it just contains a reference to the log4j2.xml file. Change etc/org.ops4j.pax.logging.cfg to

org.ops4j.pax.logging.log4j2.config.file=${karaf.base}/etc/log4j2.xml
log4j.rootLogger = INFO

Setting the log level is optional

To use system properties in log4j's config file, just use the sys: prefix like

<File name="File" fileName="${sys:karaf.data}/log/karaf.log">

Finally you need to configure the appender from Pax Logging inside log4j's config xml file (e.g. etc/log4j2.xml) with

<PaxOsgi name="PaxOsgi" filter="VmLogAppender"/>

Choose the appender name you like, but Pax Logging registers its service with the name VmLogAppender.