简体   繁体   中英

Apache karaf - How to log:display a 'lot' of information?

Working with karaf 2.2.9 on linux ubuntu servers, I have a karaf command which launches a some code. This generates some detailed functionnal log in the karaf.log This command is executed regularly (every 2 hours).

We want to collect the log corresponding to each execution.


We have a script shell which uses the client karaf to do the following :

  1. Execute log:clear ==> this puts a marker that will prevent any future log:display command to go before this marker
  2. Execute our command ==> this writes things in the log
  3. Execute log:display -n 0 ==> this gets the log between the previous log:clear and now
  4. Writes the result in a file for later statistics and analysing

All this is repeated every two hours.

In order to not limit too much the output, I have modified the "size" parameter in karaf/etc/org.apache.karaf.log.cfg to a higher value.


Sometimes, the output can be very rich (and of course, the richer it is, the more critical it becomes!).
So :

  • if I put the "size" parameter too low, the log:display does not take all the required log
  • if I put the "size" parameter too high, karaf hangs in an out of memory
    I have already increased karaf xmx memory. The documentation on the "log" commands is very poor. In fact, there is no explanation how this log system works (or I couldn't find it).


Is there a way to increase something so that I can take a rather comfortable amount of log between a log:clear and a log:display ?

Of course, other solutions could be considered, like remaking entirely the logging method or the program, but it would cost far much more than finding the right parameter for a system which already runs.

The default log service used in Karaf is ops4j pax logging .

You can setup the logging-System with the file karaf/etc/org.ops4j.pax.logging.cfg This is a log4j-like configuration file. Here you can setup your own appenders and loggers, adjust the file size, backup-index, etc...

This way you can extract specific logging-information into different log-files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM