简体   繁体   English

Apache karaf - 如何记录:显示“大量”信息?

[英]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.在 linux ubuntu 服务器上使用 karaf 2.2.9,我有一个 karaf 命令可以启动一些代码。 This generates some detailed functionnal log in the karaf.log This command is executed regularly (every 2 hours).这会在 karaf.log 中生成一些详细的功能日志 该命令会定期(每 2 小时)执行一次。

We want to collect the log corresponding to each execution.我们要收集每次执行对应的日志。

What we already do :我们已经在做的:
We have a script shell which uses the client karaf to do the following :我们有一个脚本 shell,它使用客户端 karaf 执行以下操作:

  1. Execute log:clear ==> this puts a marker that will prevent any future log:display command to go before this marker执行 log:clear ==> 这会放置一个标记,以防止任何未来的 log:display 命令在此标记之前执行
  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执行 log:display -n 0 ==> 这将获取上一个 log:clear 和 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.为了不过多限制输出,我将 karaf/etc/org.apache.karaf.log.cfg 中的“size”参数修改为更高的值。

Problem :问题 :
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如果我将“size”参数设置得太低,则 log:display 不会获取所有必需的日志
  • if I put the "size" parameter too high, karaf hangs in an out of memory如果我将“大小”参数设置得太高,karaf 就会挂起内存不足
    I have already increased karaf xmx memory.我已经增加了 karaf xmx 内存。 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).事实上,没有解释这个日志系统是如何工作的(或者我找不到它)。

My question :我的问题 :
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 ?有没有办法增加一些东西,以便我可以在 log:clear 和 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 . Karaf 中使用的默认日志服务是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.您可以使用文件 karaf/etc/org.ops4j.pax.logging.cfg 设置日志系统。这是一个类似 log4j 的配置文件。 Here you can setup your own appenders and loggers, adjust the file size, backup-index, etc...在这里你可以设置你自己的 appender 和 loggers,调整文件大小,备份索引等......

This way you can extract specific logging-information into different log-files.通过这种方式,您可以将特定的日志信息提取到不同的日志文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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