Pax Exam - Examine the Karaf logs as part of test

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

Pax Exam - Examine the Karaf logs as part of test

Kerry
Hi,

I'm just starting to use Pax exam with Karaf and I am writing a very simple test. All I want it to do is to examine the log files of Karaf to see if a specific bundle has successfully deployed. The bundle contains a native library and I load this using a Blueprint bean. If the library loads then a 'load successful' entry is written to the logs.

Is there any easy way of examining the logs in the test?

Thanks, Kerry

Reply | Threaded
Open this post in threaded view
|

Re: Pax Exam - Examine the Karaf logs as part of test

jbonofre
Hi Kerry,

you can access the LogService LRU (as the log:display command does).

Anyway, I would recommend to use bundle service to check the state
instead of log.

Regards
JB

On 03/07/2017 09:13 PM, JT wrote:

> Hi,
>
> I'm just starting to use Pax exam with Karaf and I am writing a very
> simple test. All I want it to do is to examine the log files of Karaf to
> see if a specific bundle has successfully deployed. The bundle contains
> a native library and I load this using a Blueprint bean. If the library
> loads then a 'load successful' entry is written to the logs.
>
> Is there any easy way of examining the logs in the test?
>
> Thanks, Kerry
>

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

Re: Pax Exam - Examine the Karaf logs as part of test

Kerry
Hi JB,

Thanks. I knew the answer was simple and staring me in the face!

Kerry


On 07/03/17 20:23, Jean-Baptiste Onofré wrote:

> Hi Kerry,
>
> you can access the LogService LRU (as the log:display command does).
>
> Anyway, I would recommend to use bundle service to check the state instead of log.
>
> Regards
> JB
>
> On 03/07/2017 09:13 PM, JT wrote:
>> Hi,
>>
>> I'm just starting to use Pax exam with Karaf and I am writing a very
>> simple test. All I want it to do is to examine the log files of Karaf to
>> see if a specific bundle has successfully deployed. The bundle contains
>> a native library and I load this using a Blueprint bean. If the library
>> loads then a 'load successful' entry is written to the logs.
>>
>> Is there any easy way of examining the logs in the test?
>>
>> Thanks, Kerry
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Pax Exam - Examine the Karaf logs as part of test

Kerry
In reply to this post by jbonofre
Hi,

I don't know if I am doing something wrong but when I use LogReaderService and get the logs using getLog(), the Enumeration is of size 100 and I don't find the expected message in there, even though I know it has been logged (by manually inspecting the logs). I also know the log is greater than 100 entries in size and 100 does seem to convenient a size. Do I need some sort of additional configuration to the logging?  (I aleady set LogLevel to INFO in KarafDistributionconfiguration.

Thanks, Kerry

On 07/03/17 20:23, Jean-Baptiste Onofré wrote:

> Hi Kerry,
>
> you can access the LogService LRU (as the log:display command does).
>
> Anyway, I would recommend to use bundle service to check the state instead of log.
>
> Regards
> JB
>
> On 03/07/2017 09:13 PM, JT wrote:
>> Hi,
>>
>> I'm just starting to use Pax exam with Karaf and I am writing a very
>> simple test. All I want it to do is to examine the log files of Karaf to
>> see if a specific bundle has successfully deployed. The bundle contains
>> a native library and I load this using a Blueprint bean. If the library
>> loads then a 'load successful' entry is written to the logs.
>>
>> Is there any easy way of examining the logs in the test?
>>
>> Thanks, Kerry
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Pax Exam - Examine the Karaf logs as part of test

James Carman
Another approach to make sure your bundle started properly is to use @Inject to inject any services that are started/exposed by your bundle.  Your @Test won't run until everything is injected properly:

https://ops4j1.jira.com/wiki/display/PAXEXAM4/Getting+Started+with+OSGi+Tests

On Wed, Mar 8, 2017 at 3:59 PM JT <[hidden email]> wrote:
Hi,

I don't know if I am doing something wrong but when I use LogReaderService and get the logs using getLog(), the Enumeration is of size 100 and I don't find the expected message in there, even though I know it has been logged (by manually inspecting the logs). I also know the log is greater than 100 entries in size and 100 does seem to convenient a size. Do I need some sort of additional configuration to the logging?  (I aleady set LogLevel to INFO in KarafDistributionconfiguration.

Thanks, Kerry

On 07/03/17 20:23, Jean-Baptiste Onofré wrote:
> Hi Kerry,
>
> you can access the LogService LRU (as the log:display command does).
>
> Anyway, I would recommend to use bundle service to check the state instead of log.
>
> Regards
> JB
>
> On 03/07/2017 09:13 PM, JT wrote:
>> Hi,
>>
>> I'm just starting to use Pax exam with Karaf and I am writing a very
>> simple test. All I want it to do is to examine the log files of Karaf to
>> see if a specific bundle has successfully deployed. The bundle contains
>> a native library and I load this using a Blueprint bean. If the library
>> loads then a 'load successful' entry is written to the logs.
>>
>> Is there any easy way of examining the logs in the test?
>>
>> Thanks, Kerry
>>
>