简体   繁体   English

如何查看我的Opendaylight项目中的调试日志

[英]How to see debug logs from my Opendaylight project

I created a project using MD-SAL Startup Archetype and added some debug logs to check the code. 我使用MD-SAL启动原型创建了一个项目,并添加了一些调试日志来检查代码。 The project is compiled and installed successfully. 该项目已编译并成功安装。 But after running karaf and log:display, I can't seem me to find any of the logs I entered. 但是在运行karaf和log:display之后,我似乎无法找到我输入的任何日志。 I'm new using ODL and probably am missing something. 我是使用ODL的新手,可能丢失了一些东西。 Can someone help me on how to search for the logs I need? 有人可以帮助我如何搜索所需的日志吗? For example, I read somewhere that we can do setLogLevelorg.opendaylight.bundlename TRACE or DEBUG for a specific bundle but in my case, the startup archetype created a folder containing several other from api, features, karaf to impl folders. 例如,我读过某处可以为特定的捆绑软件设置setLogLevelorg.opendaylight.bundlename TRACE or DEBUG的示例,但就我而言,启动原型创建了一个文件夹,其中包含从api,功能,karaf到impl文件夹的其他文件夹。 I added code mainly in the impl folder and created different classes, each of these classes have debug logs that I wanted to check, so how do I specify the bundle name and path in this case? 我主要在impl文件夹中添加了代码,并创建了不同的类,这些类中的每一个都具有要检查的调试日志,因此在这种情况下如何指定包名称和路径? And where should I use that code? 我应该在哪里使用该代码? Because in the karaf console I can only do log:list, log:display DEBUG , etc. I'm sorry if this a confusing question but would appreciate any help. 因为在karaf控制台中,我只能执行log:list, log:display DEBUG等。对于这个令人困惑的问题,我们深表歉意,但不胜感激。

Thanks! 谢谢!

It is not a bundle name you specify with the set log level command but a fully-qualified Java package or class name. 它不是使用set log level命令指定的捆绑包名称,而是完全限定的Java包或类名称。 You can also just edit etc/org.ops4j.pax.logging.cfg directly to set the log levels for packages/classes, for example: 您也可以直接编辑etc / org.ops4j.pax.logging.cfg来设置包/类的日志级别,例如:

log4j.logger.org.opendaylight.mypackage=DEBUG

In code you create Logger instances per class, for example: 在代码中,您可以为每个类创建Logger实例,例如:

package org.opendaylight.mypackage;

public class MyClass {
    private static final Logger LOG = LoggerFactory.getLogger(MyClass.class);
    ...
}

Log output goes to data/log/karaf.log . 日志输出转到data / log / karaf.log

From the karaf CLI you can execute below commands. 在karaf CLI中,您可以执行以下命令。

  1. To set log levels for particular package. 为特定程序包设置日志级别。

     log:set debug <your package name> 
  2. To view logs 查看日志

     log:tail 

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

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