You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Charles Moulliard <ch...@gmail.com> on 2015/12/04 12:27:32 UTC

Issue with Pax OPS4J Log4j2 on Karaf 4.2

Hi,

I have configured log4j2 on Karaf 2.4 as such

- Edit the file etc/startup.properties file and comment this line
`org/ops4j/pax/logging/pax-logging-service/1.8.4/pax-logging-service-1.8.4.jar=8`
- Add this line after the commented line
'org/ops4j/pax/logging/pax-logging-log4j2/1.8.4/pax-logging-log4j2-1.8.4.jar=8'

- Configure `org.ops4j.pax.logging.cfg` file by adding this line
'org.ops4j.pax.logging.log4j2.config.file=${karaf.etc}/log4j2.xml'

- Add a log4j.xml file

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
    <Appenders>
        <Console name="console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{ABSOLUTE} | %-5.5p | %-16.16t |
%-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n"/>
        </Console>
        <RollingFile name="out" fileName="${karaf.data}/log/fuse.log"
              append="true"
filePattern="${karaf.data}/log/$${date:yyyy-MM}/fuse-%d{MM-dd-yyyy}-%i.log.gz">
           <PatternLayout>
             <Pattern>%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %X{
bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n</Pattern>
           </PatternLayout>
           <Policies>
                <TimeBasedTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="250 MB"/>
            </Policies>
        </RollingFile>
        <PaxOsgi name="paxosgi" filter="VmLogAppender"/>
    </Appenders>
    <Loggers>
        <Root level="INFO">
            <AppenderRef ref="console"/>
            <AppenderRef ref="out"/>
            <AppenderRef ref="paxosgi"/>
        </Root>
    </Loggers>
</Configuration>

but when I try to change the log level, I get this error

JBossFuse:karaf@root> log:set DEBUG io.apiman
JBossFuse:karaf@root> 12:22:55,086 | ERROR | s4j.pax.logging) | configadmin
                     | 7 - org.apache.felix.configadmin - 1.8.4 | Cannot
use configuration org.ops4j.pax.logging for
[org.osgi.service.log.LogService, org.knopflerfish.service.log.LogService,
org.ops4j.pax.logging.PaxLoggingService,
org.osgi.service.cm.ManagedService, id=13,
bundle=65/mvn:org.ops4j.pax.logging/pax-logging-service/1.8.4]: No
visibility to configuration bound to
mvn:org.ops4j.pax.logging/pax-logging-log4j2/1.8.4

IS there something else to configure ?

Regards

-- 
Charles Moulliard
Apache Committer & PMC / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: Issue with Pax OPS4J Log4j2 on Karaf 4.2

Posted by Charles Moulliard <ch...@gmail.com>.
Done : https://ops4j1.jira.com/browse/PAXLOGGING-205

On Fri, Dec 4, 2015 at 1:54 PM, Jean-Baptiste Onofré <jb...@nanthrax.net>
wrote:

> Hi Charles,
>
> It looks like the org.ops4j.pax.logging configuration is bound to two
> bundles: pax-logging-log4j and pax-logging-service use the same
> configuration (which is not allowed for ManagedService).
>
> It's a bug for me.
>
> Can you create the Jira please ? I will fix that.
>
> Regards
> JB
>
> On 12/04/2015 12:27 PM, Charles Moulliard wrote:
>
>> Hi,
>>
>> I have configured log4j2 on Karaf 2.4 as such
>>
>> - Edit the file etc/startup.properties file and comment this line
>>
>> `org/ops4j/pax/logging/pax-logging-service/1.8.4/pax-logging-service-1.8.4.jar=8`
>> - Add this line after the commented line
>>
>> 'org/ops4j/pax/logging/pax-logging-log4j2/1.8.4/pax-logging-log4j2-1.8.4.jar=8'
>>
>> - Configure `org.ops4j.pax.logging.cfg` file by adding this line
>> 'org.ops4j.pax.logging.log4j2.config.file=${karaf.etc}/log4j2.xml'
>>
>> - Add a log4j.xml file
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <Configuration status="INFO">
>>      <Appenders>
>>          <Console name="console" target="SYSTEM_OUT">
>>              <PatternLayout pattern="%d{ABSOLUTE} | %-5.5p | %-16.16t |
>> %-32.32c{1} | %X{bundle.id <http://bundle.id>} - %X{bundle.name
>> <http://bundle.name>} - %X{bundle.version} | %m%n"/>
>>          </Console>
>>          <RollingFile name="out" fileName="${karaf.data}/log/fuse.log"
>>                append="true"
>>
>> filePattern="${karaf.data}/log/$${date:yyyy-MM}/fuse-%d{MM-dd-yyyy}-%i.log.gz">
>>             <PatternLayout>
>>               <Pattern>%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} |
>> %X{bundle.id <http://bundle.id>} - %X{bundle.name <http://bundle.name>}
>>
>> - %X{bundle.version} | %m%n</Pattern>
>>             </PatternLayout>
>>             <Policies>
>>                  <TimeBasedTriggeringPolicy />
>>                  <SizeBasedTriggeringPolicy size="250 MB"/>
>>              </Policies>
>>          </RollingFile>
>>          <PaxOsgi name="paxosgi" filter="VmLogAppender"/>
>>      </Appenders>
>>      <Loggers>
>>          <Root level="INFO">
>>              <AppenderRef ref="console"/>
>>              <AppenderRef ref="out"/>
>>              <AppenderRef ref="paxosgi"/>
>>          </Root>
>>      </Loggers>
>> </Configuration>
>>
>> but when I try to change the log level, I get this error
>>
>> JBossFuse:karaf@root> log:set DEBUG io.apiman
>> JBossFuse:karaf@root> 12:22:55,086 | ERROR | s4j.pax.logging) |
>> configadmin                      | 7 - org.apache.felix.configadmin -
>> 1.8.4 | Cannot use configuration org.ops4j.pax.logging for
>> [org.osgi.service.log.LogService,
>> org.knopflerfish.service.log.LogService,
>> org.ops4j.pax.logging.PaxLoggingService,
>> org.osgi.service.cm.ManagedService, id=13,
>> bundle=65/mvn:org.ops4j.pax.logging/pax-logging-service/1.8.4]: No
>> visibility to configuration bound to
>> mvn:org.ops4j.pax.logging/pax-logging-log4j2/1.8.4
>>
>> IS there something else to configure ?
>>
>> Regards
>>
>> --
>> Charles Moulliard
>> Apache Committer & PMC / Architect @RedHat
>> Twitter : @cmoulliard | Blog : http://cmoulliard.github.io
>> <http://cmoulliard.github.io>
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>



-- 
Charles Moulliard
Apache Committer & PMC / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: Issue with Pax OPS4J Log4j2 on Karaf 4.2

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Charles,

It looks like the org.ops4j.pax.logging configuration is bound to two 
bundles: pax-logging-log4j and pax-logging-service use the same 
configuration (which is not allowed for ManagedService).

It's a bug for me.

Can you create the Jira please ? I will fix that.

Regards
JB

On 12/04/2015 12:27 PM, Charles Moulliard wrote:
> Hi,
>
> I have configured log4j2 on Karaf 2.4 as such
>
> - Edit the file etc/startup.properties file and comment this line
> `org/ops4j/pax/logging/pax-logging-service/1.8.4/pax-logging-service-1.8.4.jar=8`
> - Add this line after the commented line
> 'org/ops4j/pax/logging/pax-logging-log4j2/1.8.4/pax-logging-log4j2-1.8.4.jar=8'
>
> - Configure `org.ops4j.pax.logging.cfg` file by adding this line
> 'org.ops4j.pax.logging.log4j2.config.file=${karaf.etc}/log4j2.xml'
>
> - Add a log4j.xml file
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="INFO">
>      <Appenders>
>          <Console name="console" target="SYSTEM_OUT">
>              <PatternLayout pattern="%d{ABSOLUTE} | %-5.5p | %-16.16t |
> %-32.32c{1} | %X{bundle.id <http://bundle.id>} - %X{bundle.name
> <http://bundle.name>} - %X{bundle.version} | %m%n"/>
>          </Console>
>          <RollingFile name="out" fileName="${karaf.data}/log/fuse.log"
>                append="true"
> filePattern="${karaf.data}/log/$${date:yyyy-MM}/fuse-%d{MM-dd-yyyy}-%i.log.gz">
>             <PatternLayout>
>               <Pattern>%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} |
> %X{bundle.id <http://bundle.id>} - %X{bundle.name <http://bundle.name>}
> - %X{bundle.version} | %m%n</Pattern>
>             </PatternLayout>
>             <Policies>
>                  <TimeBasedTriggeringPolicy />
>                  <SizeBasedTriggeringPolicy size="250 MB"/>
>              </Policies>
>          </RollingFile>
>          <PaxOsgi name="paxosgi" filter="VmLogAppender"/>
>      </Appenders>
>      <Loggers>
>          <Root level="INFO">
>              <AppenderRef ref="console"/>
>              <AppenderRef ref="out"/>
>              <AppenderRef ref="paxosgi"/>
>          </Root>
>      </Loggers>
> </Configuration>
>
> but when I try to change the log level, I get this error
>
> JBossFuse:karaf@root> log:set DEBUG io.apiman
> JBossFuse:karaf@root> 12:22:55,086 | ERROR | s4j.pax.logging) |
> configadmin                      | 7 - org.apache.felix.configadmin -
> 1.8.4 | Cannot use configuration org.ops4j.pax.logging for
> [org.osgi.service.log.LogService,
> org.knopflerfish.service.log.LogService,
> org.ops4j.pax.logging.PaxLoggingService,
> org.osgi.service.cm.ManagedService, id=13,
> bundle=65/mvn:org.ops4j.pax.logging/pax-logging-service/1.8.4]: No
> visibility to configuration bound to
> mvn:org.ops4j.pax.logging/pax-logging-log4j2/1.8.4
>
> IS there something else to configure ?
>
> Regards
>
> --
> Charles Moulliard
> Apache Committer & PMC / Architect @RedHat
> Twitter : @cmoulliard | Blog : http://cmoulliard.github.io
> <http://cmoulliard.github.io>
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com