You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Shripati Bhat <sh...@onmobile.com> on 2012/05/27 21:44:51 UTC

ServiceMix4.4 Custom RollingFileAppender and Layout help

Hi All,
                I am a newbie to ServiceMix. I wanted a way to configure ServiceMix's pax logger to Include my custom rollingfileappender and layout.

For Example
<code>
#Debug logs
log4j.appender.DebugLogs=com.smx.log.core.MyRollingFileAppender
log4j.appender.DebugLogs.File=C:/logs/debug/MyDebug.log
log4j.appender.DebugLogs.MaxFileSize=50KB
log4j.appender.DebugLogs.append=true
log4j.appender.DebugLogs.layout=com.smx.log.core.MyLayout

log4j.logger.MyDebugLogs= DEBUG, DebugLogs
</code>

Or my custom log4j.xml.

1.       Putting a myGroupId.cfg file in /etc folder does not work as it does not pick it

2.       Putting a log4j.xml in /etc folder also dosen't work.

3.       Putting the "MyRollingFileAppender" and "MyLayout" classes in org.ops4j.pax.logging/pax-logging-service/1.6.3/ pax-logging-service-1.6.3.jar and the related config (loggers and appenders) in org.ops4j.pax.logging.cfg works but this is not how I want it. Because I cannot have my own logging bundle and need to manipulate pax logging jar everytime.

Any help is truly appreciated.

Regards,
Shripati Bhat


________________________________

DISCLAIMER: The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful. Please immediately contact the sender if you have received this message in error. Further, this e-mail may contain viruses and all reasonable precaution to minimize the risk arising there from is taken by OnMobile. OnMobile is not liable for any damage sustained by you as a result of any virus in this e-mail. All applicable virus checks should be carried out by you before opening this e-mail or any attachment thereto.
Thank you - OnMobile Global Limited.

Re: ServiceMix4.4 Custom RollingFileAppender and Layout help

Posted by Shripati Bhat <sh...@onmobile.com>.
Hey.. That worked for me.. I had not included the
/*;scope=compile|runtime;inline=true</embed-Dependency>/ tag.. 

Thanks a lot Filippo for your help. 

Regards,
Shripati.

--
View this message in context: http://servicemix.396122.n5.nabble.com/ServiceMix4-4-Custom-RollingFileAppender-and-Layout-help-tp5713390p5713623.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: ServiceMix4.4 Custom RollingFileAppender and Layout help

Posted by Shripati Bhat <sh...@onmobile.com>.
Hi Filippo,
         
            I am sorry for so late reply. Actually I had to park this task
for something more important. But now when I try, I am following the blog 
http://nierbeck.de/cgi-bin/weblog_basic/index.php?p=201
http://nierbeck.de/cgi-bin/weblog_basic/index.php?p=201  This is in
accordance to what you suggested. But I am getting the following ERROR

ERROR: Bundle org.ops4j.pax.logging.pax-logging-service [6] Error starting
mvn:org.ops4j.pax.logging/pax-logging-service/1.6.3
(org.osgi.framework.BundleException: A
ctivator start error in bundle org.ops4j.pax.logging.pax-logging-service
[6].)
java.lang.NoClassDefFoundError: org/apache/log4j/PaxLoggingConfigurator
        at
org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl.configureDefaults(PaxLoggingServiceImpl.java:251)
        at
org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl.<init>(PaxLoggingServiceImpl.java:61)
        at
org.ops4j.pax.logging.service.internal.Activator.start(Activator.java:108)
        at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1842)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1759)
        at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1163)
        at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException:
org.apache.log4j.PaxLoggingConfigurator not found by
org.ops4j.pax.logging.pax-logging-api [7]
        at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
        at
org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
        at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at
org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)
        at
org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99)
        at
org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1390)
        at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:722)
        at
org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
        at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 9 more

The pax-logging-service itself isnt coming up.. 


Filippo Balicchia wrote
> 
> When the framework resolves a bundle, it searches the installed 
> bundles to see if there 
> are any fragments for it. 
> said this, removes the bundle activator, platform import pakage ecc.ecc. 
> 
> If you still have problems tell me that i send you an axample 
> 
> cheers 
> 
> -Filippo 
> 

Can you please share a sample example.. 

Regards,
Shripati 

--
View this message in context: http://servicemix.396122.n5.nabble.com/ServiceMix4-4-Custom-RollingFileAppender-and-Layout-help-tp5713390p5713621.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: ServiceMix4.4 Custom RollingFileAppender and Layout help

Posted by Filippo Balicchia <fb...@gmail.com>.
>From my point of view you need to expose a service that save data to DB.
In your fragment you need to create you appender that send data to service.
The only thing you need is to import interface of your service.

Cheers.

--Filippo



2012/5/29 Shripati Bhat <sh...@onmobile.com>:
> Hi,
>    Thanks for the help Filippo.
>
> This is what i exactly did. And it worked great. But my custom
> rollingfileappender needs imports. If my RollingFileAppender is dependent on
> some other bundle, and I need to include Import-Package statements, it is
> not working. For me, as a use case I have to update DB every time the file
> rolls over. This is what my customRollingFileAppender does.. So I need to
> Import the DB related service to which I will pass.
>
> how do we achieve this? Can the import be included in the Host bundle's
> configuration? I mean here, I will change the
> org.ops4j.pax.logging.pax-logging-service bundle's MANIFEST.MF to include
> the Import-Package say com.smx.app.db?
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/ServiceMix4-4-Custom-RollingFileAppender-and-Layout-help-tp5713390p5713400.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: ServiceMix4.4 Custom RollingFileAppender and Layout help

Posted by Shripati Bhat <sh...@onmobile.com>.
Hi,
    Thanks for the help Filippo.

This is what i exactly did. And it worked great. But my custom
rollingfileappender needs imports. If my RollingFileAppender is dependent on
some other bundle, and I need to include Import-Package statements, it is
not working. For me, as a use case I have to update DB every time the file
rolls over. This is what my customRollingFileAppender does.. So I need to
Import the DB related service to which I will pass. 

how do we achieve this? Can the import be included in the Host bundle's
configuration? I mean here, I will change the
org.ops4j.pax.logging.pax-logging-service bundle's MANIFEST.MF to include
the Import-Package say com.smx.app.db?

--
View this message in context: http://servicemix.396122.n5.nabble.com/ServiceMix4-4-Custom-RollingFileAppender-and-Layout-help-tp5713390p5713400.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: ServiceMix4.4 Custom RollingFileAppender and Layout help

Posted by Filippo Balicchia <fb...@gmail.com>.
Hi,
unlike normal bundles, fragments do not have their own class loader and
instead are accessed via their host's class loader.

When the framework resolves a bundle, it searches the installed
bundles to see if there
are any fragments for it.
said this, removes the bundle activator, platform import pakage ecc.ecc.

If you still have problems tell me that i send you an axample

cheers

-Filippo


2012/5/28 Shripati Bhat <sh...@onmobile.com>:
> Hi Filippo,
>
>       Thanks for the reply.. :)
>
> But this thing isn't solving the problem.
> My MANIFEST.MF now looks like
>
> Manifest-Version: 1
> Bnd-LastModified: 1338215495052
> Build-Jdk: 1.7.0_04-ea
> Built-By: shripati.bhat
> Bundle-Activator: com.smx.test.MyActivator
> Bundle-ManifestVersion: 2
> Bundle-Name: Test_Log_Bundle_Name
> Bundle-SymbolicName: Test_Log_Symb_Name
> Bundle-Version: 1.0.0
> Created-By: Apache Maven Bundle Plugin
> Export-Package: com.smx.log.service;uses:="org.apache.log4j";ve
>  rsion="1.0.0",com.smx.log.core;uses:="org.apache.log4j,org.cod
>  ehaus.jackson.map,org.apache.log4j.spi,org.apache.log4j.helpers";versio
>  n="1.0.0"
> Fragment-Host: org.ops4j.pax.logging.pax-logging-service
> Import-Package: org.apache.log4j;version="[
>  1.2,2)",org.apache.log4j.helpers,org.apache.log4j.spi;version="[1.2,2)"
>  ,org.codehaus.jackson.map;version="[1.9,2)",org.osgi.framework;version=
>  "[1.5,2)"
> Tool: Bnd-1.43.0
>
>
>
> Now when I start ServiceMix with my custom bundle, I get
>
> ERROR: Bundle org.ops4j.pax.logging.pax-logging-service [3] Error starting
> mvn:org.ops4j.pax.logging/pax-logging-service/1.6.3
> (org.osgi.framework.BundleException: A
> ctivator start error in bundle org.ops4j.pax.logging.pax-logging-service
> [3].)
> java.lang.NoClassDefFoundError:
> org/ops4j/pax/logging/service/internal/AppenderBridgeImpl
>        at
> org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl.configureDefaults(PaxLoggingServiceImpl.java:251)
>        at
> org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl.<init>(PaxLoggingServiceImpl.java:61)
>        at
> org.ops4j.pax.logging.service.internal.Activator.start(Activator.java:108)
>        at
> org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
>        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1842)
>        at org.apache.felix.framework.Felix.startBundle(Felix.java:1759)
>        at
> org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1163)
>        at
> org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.ClassNotFoundException:
> org.ops4j.pax.logging.service.internal.AppenderBridgeImpl not found by
> org.ops4j.pax.logging.pax-logging-api [4]
>        at
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
>        at
> org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
>        at
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>        ... 9 more
>
>
> When I checked both the pax-logging-api and pax-logging-service bundles,
> they seemed fine with all classes in place. And if I start servicemix
> without my custom bundle, It starts fine.
>
> Am I doing something wrong?
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/ServiceMix4-4-Custom-RollingFileAppender-and-Layout-help-tp5713390p5713392.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: ServiceMix4.4 Custom RollingFileAppender and Layout help

Posted by Shripati Bhat <sh...@onmobile.com>.
Hi Filippo,
  
       Thanks for the reply.. :) 

But this thing isn't solving the problem.
My MANIFEST.MF now looks like 

Manifest-Version: 1
Bnd-LastModified: 1338215495052
Build-Jdk: 1.7.0_04-ea
Built-By: shripati.bhat
Bundle-Activator: com.smx.test.MyActivator
Bundle-ManifestVersion: 2
Bundle-Name: Test_Log_Bundle_Name
Bundle-SymbolicName: Test_Log_Symb_Name
Bundle-Version: 1.0.0
Created-By: Apache Maven Bundle Plugin
Export-Package: com.smx.log.service;uses:="org.apache.log4j";ve
 rsion="1.0.0",com.smx.log.core;uses:="org.apache.log4j,org.cod
 ehaus.jackson.map,org.apache.log4j.spi,org.apache.log4j.helpers";versio
 n="1.0.0"
Fragment-Host: org.ops4j.pax.logging.pax-logging-service
Import-Package: org.apache.log4j;version="[
 1.2,2)",org.apache.log4j.helpers,org.apache.log4j.spi;version="[1.2,2)"
 ,org.codehaus.jackson.map;version="[1.9,2)",org.osgi.framework;version=
 "[1.5,2)"
Tool: Bnd-1.43.0



Now when I start ServiceMix with my custom bundle, I get 

ERROR: Bundle org.ops4j.pax.logging.pax-logging-service [3] Error starting
mvn:org.ops4j.pax.logging/pax-logging-service/1.6.3
(org.osgi.framework.BundleException: A
ctivator start error in bundle org.ops4j.pax.logging.pax-logging-service
[3].)
java.lang.NoClassDefFoundError:
org/ops4j/pax/logging/service/internal/AppenderBridgeImpl
        at
org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl.configureDefaults(PaxLoggingServiceImpl.java:251)
        at
org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl.<init>(PaxLoggingServiceImpl.java:61)
        at
org.ops4j.pax.logging.service.internal.Activator.start(Activator.java:108)
        at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1842)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1759)
        at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1163)
        at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException:
org.ops4j.pax.logging.service.internal.AppenderBridgeImpl not found by
org.ops4j.pax.logging.pax-logging-api [4]
        at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
        at
org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
        at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 9 more


When I checked both the pax-logging-api and pax-logging-service bundles,
they seemed fine with all classes in place. And if I start servicemix
without my custom bundle, It starts fine. 

Am I doing something wrong? 

--
View this message in context: http://servicemix.396122.n5.nabble.com/ServiceMix4-4-Custom-RollingFileAppender-and-Layout-help-tp5713390p5713392.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: ServiceMix4.4 Custom RollingFileAppender and Layout help

Posted by Filippo Balicchia <fb...@gmail.com>.
Hi,
please check http://karaf.apache.org/manual/latest-2.2.x/users-guide/logging-system.html
the last paragraph.

Regards

--Filippo

2012/5/27 Shripati Bhat <sh...@onmobile.com>:
> Hi All,
>                I am a newbie to ServiceMix. I wanted a way to configure ServiceMix's pax logger to Include my custom rollingfileappender and layout.
>
> For Example
> <code>
> #Debug logs
> log4j.appender.DebugLogs=com.smx.log.core.MyRollingFileAppender
> log4j.appender.DebugLogs.File=C:/logs/debug/MyDebug.log
> log4j.appender.DebugLogs.MaxFileSize=50KB
> log4j.appender.DebugLogs.append=true
> log4j.appender.DebugLogs.layout=com.smx.log.core.MyLayout
>
> log4j.logger.MyDebugLogs= DEBUG, DebugLogs
> </code>
>
> Or my custom log4j.xml.
>
> 1.       Putting a myGroupId.cfg file in /etc folder does not work as it does not pick it
>
> 2.       Putting a log4j.xml in /etc folder also dosen't work.
>
> 3.       Putting the "MyRollingFileAppender" and "MyLayout" classes in org.ops4j.pax.logging/pax-logging-service/1.6.3/ pax-logging-service-1.6.3.jar and the related config (loggers and appenders) in org.ops4j.pax.logging.cfg works but this is not how I want it. Because I cannot have my own logging bundle and need to manipulate pax logging jar everytime.
>
> Any help is truly appreciated.
>
> Regards,
> Shripati Bhat
>
>
> ________________________________
>
> DISCLAIMER: The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful. Please immediately contact the sender if you have received this message in error. Further, this e-mail may contain viruses and all reasonable precaution to minimize the risk arising there from is taken by OnMobile. OnMobile is not liable for any damage sustained by you as a result of any virus in this e-mail. All applicable virus checks should be carried out by you before opening this e-mail or any attachment thereto.
> Thank you - OnMobile Global Limited.