[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [equinox-dev] Using Log4J in Equinox framework

Strange... Try adding "-clean" to your launch configuration command line
arguments.
If that doesn't help, add "-console -consolelog -debug". This will give you
additional logging output, and take you to the equinox console. from there,
run the "ss" command. what is the state of your bundles?

regards,
martin

On Fri, 5 Jun 2009 12:19:02 +0200, "David Conde" <dconde@xxxxxxxx> wrote:
> Hi again,
> 
> I have problems again, the first time when I tried what you told me it
> worked fine, but next times I have always got the next exception:
> 
> "log4j:Error Could not read configuration file [log4j.properties]"
> 
> I don't really know why the first time I got no exception at all, and
next
> times I get it, my steps were the next ones:
> 
> 1-Download org.spring.lo4j bundle,
> 2-I installed it in Equinox platform
> 3- Create a new Project without Activator class where there is just a
> log4j.properties in root file (scr in Eclipse). 
> 4- Include Host-Fragment: org.spring.lo4j in Manifest.MF file for this
new
> Project
> 5- Include Bundle-Required: org.spring.lo4j in the bunde where I am going
> to use Log4J API
> 6- Delete log4j.jar as a library of my application bundle
> 
> Any idea?
> 
> Thank you in advance 
> 
> -----Mensaje original-----
> De: equinox-dev-bounces@xxxxxxxxxxx
> [mailto:equinox-dev-bounces@xxxxxxxxxxx] En nombre de Martin Below
> Enviado el: jueves, 04 de junio de 2009 13:25
> Para: Equinox development mailing list
> Asunto: Re: [equinox-dev] Using Log4J in Equinox framework
> 
> Sorry, I copy and pasted the log4j bundle name from the spring homepage, 
> which accidentally added some weird pipe-characters to my mail... Of 
> course, you have to leave them out.
> 
> Martin Below schrieb:
>> David Conde schrieb:
>> Hi David,
>>
>> consider the following layout:
>>
>> Bundle1: LibraryStoreBundle (your application, I guess)
>> Bundle2: LibraryStoreBundle.logging.config (your logging configuration 
>> bundle)
>> Bundle3: com.springsource.org.apache.log4j (download it from here: 
>> http://www.springsource.com/repository/app/search?query=log4j)
>>
>> - Add com.springsource.org.apache.log4j-1.2.15.jar to your 
>> Target-Platform. If you are not using a target platform, put it 
>> directly into your /eclipse/plugins/ - directory. (You need to restart 
>> eclipse in the later case)
>>
>> - Remove log4j.jar from your LibraryStoreBundle.
>> Add a dependency from Bundle1 to com.springsource.org.apache.log4j 
>> (open your plugin.xml file with the pde tools, go to the dependency
tab).
>>
>> . Create the bundl3: On the first page of the "new Plugin Project 
>> wizard", selected "an OSGi Framework: standard". In the newly created 
>> project, open the META-INF/manifest.mf file. You should see the "host 
>> plugin" input field on the first page of the manifest editor. Set this 
>> to "com.springsource.org.apache.log4j". (this is equivalent to putting 
>> the "fragment-host"-line to the manifest. This makes sure that your 
>> logging-config bundle will be loaded together with the log4j bundle.
>> - Put your log4j.properties-file to the root of the 
>> LibraryStoreBundle.logging.config project.
>>
>> Update your launch configuration: Open the run configuration for your 
>> plugin (run/run configurations) Open the PlugIns-Tab, and click on 
>> "add required plugins". This should add the 
>> "com.springsource.org.apache.log4j" and the 
>> "LibraryStoreBundle.logging.config" - bundle to your launch config.
>>
>> Done!
>>
>> regards,
>> Martin Below
>>
>>
>>> Hi,
>>> Thank you for your answer
>>>
>>> I read your previous email before writting the my last one, so I 
>>> created a new bundle in which in scr file I included my 
>>> log4jproperties file and log4j.jar , I included in its classpath 
>>> org.apache.log4j.jar, and I exported this package and imported it in 
>>> my other bundle which I want to use Log4J API.
>>>
>>> I tried to include directly Fragment-Host: LibraryStoreBundle either 
>>> Fragment-Host: LibraryStoreBundle.org.apache.log4j (I mean, I write 
>>> Fragment-Host: with the name of my bundle which have lo4j.jar in its 
>>> Manifest.MF) but I get an compilation error because of cannot 
>>> recognize them, I am using Eclipse IDE, I am not sure if the problem 
>>> comes from here.
>>>
>>> What am I missing?
>>>
>>> Thank you again
>>>  
>>>
>>> -----Mensaje original-----
>>> De: equinox-dev-bounces@xxxxxxxxxxx 
>>> [mailto:equinox-dev-bounces@xxxxxxxxxxx] En nombre de Martin Below
>>> Enviado el: jueves, 04 de junio de 2009 12:28
>>> Para: Equinox development mailing list
>>> Asunto: Re: [equinox-dev] Using Log4J in Equinox framework
>>>
>>> Try placing your log4j.properties at the root of your project. also 
>>> make sure that log4j.properties is checked on the build tab of the 
>>> manifest editor.
>>> Have you read my last post? In my opinion, this is a much cleaner way 
>>> of using third party jars in an osgi environment. it also makes it 
>>> easier to distribute your bundle, because your applications can be 
>>> updated and deployed independently from its dependencies, and your 
>>> bundles will be much smaller.
>>>
>>> David Conde schrieb:
>>>  
>>>> Hi,
>>>>
>>>> Thank you for your answer,
>>>>
>>>> That was just what I wanted to do. My scenario is easy, I just 
>>>> wanted use Log4J Api in one of my bundles, the problem was that I 
>>>> did not know how to include a external library using Eclipse IDE and 
>>>> Manifest.MF, so I included in bundle Classpath firstly, then I 
>>>> exported log4J.jar and I imported log4J.jar in the same bundle since 
>>>> it is this one the only one which is going to use Log4J. After that 
>>>> If I launch my bundle with log4J, Equinox is able to recognize 
>>>> Log4J.jar but the problem now it is that Equinox is not able to find 
>>>> my log4jproperties file like you told me. I got an exception 
>>>> FileNotFoundException log4j.properties not found!
>>>>
>>>> I have included my log4j.file in the same place that my 
>>>> Activator.java, then I exported from Eclipse this Project in order 
>>>> to have a .jar bundle, could you tell me where do I have to place my 
>>>> log4jproperties file so that Equinox can locate it?
>>>>
>>>> Thank you in advance
>>>>
>>>> Regards
>>>>
>>>> David
>>>>
>>>> *De:* equinox-dev-bounces@xxxxxxxxxxx 
>>>> [mailto:equinox-dev-bounces@xxxxxxxxxxx] *En nombre de *??
>>>> *Enviado el:* jueves, 04 de junio de 2009 11:46
>>>> *Para:* Equinox development mailing list
>>>> *Asunto:* Re: [equinox-dev] Using Log4J in Equinox framework
>>>>
>>>> On Thu, Jun 4, 2009 at 4:28 PM, David Conde <dconde@xxxxxxxx 
>>>> <mailto:dconde@xxxxxxxx>> wrote:
>>>>
>>>> Hi, thank you very much for your answer.
>>>>
>>>> I have tried to download the Pax Logging binary file but I have got 
>>>> error with the web site.
>>>>
>>>> If I am not wrong, the idea would be included paxlogging bundle as a 
>>>> required bundle, in order to get the libraries log4j and 
>>>> common-logging, to launch this bundle and use in my bundle log4j as 
>>>> the same way as I did without Equinox I mean in normal java 
>>>> applications, am I missing anything?
>>>>
>>>> By the way, why I canât to load the library org.apache.log4j.jar in 
>>>> my bundle and simply to use it? If I have to use other external 
>>>> libraries, what would I have to do in order to be able to use in 
>>>> Equinox framework?
>>>>
>>>> I think the simplest way you want is to change a log4j Jar file to a 
>>>> log4j bundle. Just create a new bundle project, put log4j.jar in the 
>>>> bundle directory, add log4j.jar to the project build path, export 
>>>> all the packages in log4j.jar,(through Export-Package in bundle's 
>>>> MANIFEST.MF), add log4j to the bundle class path (through 
>>>> Bundle-Classpath in bundle's MANIFEST.MF). And then you get a log4j 
>>>> bundle which can run on Equinox.
>>>>
>>>> You want to use log4j APIs, just import log4j package in other 
>>>> bundle (through Import-Package in bundle's MANIFEST.MF) and use it 
>>>> directly. But in this way, loading of the configuration file 
>>>> log4j.properties is a problem. log4j.properties can locate in the 
>>>> jar bundle or use a argument to figure it out.
>>>>
>>>> So using pax log is a better way to resolve the class loader problem.
>>>>
>>>>     Thank you in advance
>>>>
>>>>     Regards
>>>>
>>>>     *De:* equinox-dev-bounces@xxxxxxxxxxx
>>>>     <mailto:equinox-dev-bounces@xxxxxxxxxxx>
>>>>     [mailto:equinox-dev-bounces@xxxxxxxxxxx
>>>>     <mailto:equinox-dev-bounces@xxxxxxxxxxx>] *En nombre de 
>>>> *Laidlaw, Don
>>>>     *Enviado el:* miÃrcoles, 03 de junio de 2009 14:40
>>>>     *Para:* Equinox development mailing list
>>>>     *Asunto:* Re: [equinox-dev] Using Log4J in Equinox framework
>>>>
>>>>     PAX Logging at
>>>>     http://wiki.ops4j.org/display/paxlogging/Pax+Logging is a good
>>>>     solution, and the one I use. Another good solution is SLF4J at
>>>>     http://www.slf4j.org/.
>>>>
>>>>     Both of those implement the log4j logging API and use standard
>>>>     log4j configuration property/xml formats for configuration, which
>>>>     is convenient if that is what you know.
>>>>
>>>>     Both of those also implement Commons Logging and other logging
>>>>     APIs making it very convenient in an OSGi container!
>>>>     --     Best Regards,
>>>>
>>>>     Don Laidlaw  Sr. Research Engineer  Infor  office: +1
>>>>     902-576-5185  mobile: +1 902-401-6771  don.laidlaw@xxxxxxxxx
>>>>     <http://don.laidlaw@xxxxxxxxx>
>>>>
>>>>     
>>>>
------------------------------------------------------------------------
>>>>
>>>>
>>>>
>>>>     *From: *David Conde <dconde@xxxxxxxx <http://dconde@xxxxxxxx>>
>>>>     *Reply-To: *Equinox development mailing list
>>>>     <equinox-dev@xxxxxxxxxxx <http://equinox-dev@xxxxxxxxxxx>>
>>>>     *Date: *Wed, 3 Jun 2009 13:01:18 +0200
>>>>     *To: *'Equinox development mailing list' <equinox-dev@xxxxxxxxxxx
>>>>     <http://equinox-dev@xxxxxxxxxxx>>
>>>>     *Subject: *[equinox-dev] Using Log4J in Equinox framework
>>>>
>>>>     Hi,
>>>>
>>>>     I have been trying to use org.apache.lo4j jar in Equinox but I got
>>>>     an exception :
>>>>
>>>>     Java.lang.Error Unresolved compilation problems:
>>>>
>>>>     The import org.apache cannot be resolved
>>>>     â.
>>>>
>>>>     My framework is not able either to recognize or load this library.
>>>>
>>>>     I have in my Activator. Java the next one:
>>>>
>>>>     *import* org.apache.log4j.Logger;
>>>>     *import* org._apache_.log4j.PropertyConfigurator;
>>>>
>>>>     Furthermore, I included org.apache.log4j.jar in my classpath,
>>>>     either I installed this library like a bundle. I also tried to
>>>>     install the bundle from Orbit which implemented log4J, but I
>>>>     always have the same result.
>>>>
>>>>     Does anyone know what I have to do to use org.apache.log4J in 
>>>> Equinox?
>>>>
>>>>     I have either include import org.apache.log4j in Manifest.MF, I
>>>>     guess that there is a way to load external libraries in Equinox
>>>>     framework, other times I tried directly installing the jar file
>>>>     and it was fine, but with org.apache.lo4j jar there is no way to
>>>>     get a good result.
>>>>
>>>>     Any idea?
>>>>
>>>>     I am using Equinox by Console, not through Eclipse.
>>>>
>>>>     Thank you in advance
>>>>
>>>>     
>>>>
------------------------------------------------------------------------
>>>>
>>>>
>>>>
>>>>     _______________________________________________
>>>>     equinox-dev mailing list
>>>>     equinox-dev@xxxxxxxxxxx <http://equinox-dev@xxxxxxxxxxx>
>>>>     https://dev.eclipse.org/mailman/listinfo/equinox-dev
>>>>
>>>>
>>>>     _______________________________________________
>>>>     equinox-dev mailing list
>>>>     equinox-dev@xxxxxxxxxxx <mailto:equinox-dev@xxxxxxxxxxx>
>>>>     https://dev.eclipse.org/mailman/listinfo/equinox-dev
>>>>
>>>>
------------------------------------------------------------------------
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> equinox-dev mailing list
>>>> equinox-dev@xxxxxxxxxxx
>>>> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>>>>       
>>>
>>> _______________________________________________
>>> equinox-dev mailing list
>>> equinox-dev@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>>>
>>> _______________________________________________
>>> equinox-dev mailing list
>>> equinox-dev@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>>>   
>>
>> _______________________________________________
>> equinox-dev mailing list
>> equinox-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/equinox-dev
> 
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
> 
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev