gpt4 book ai didi

java - 如何更改Kaa客户端的日志级别

转载 作者:太空宇宙 更新时间:2023-11-04 11:48:10 25 4
gpt4 key购买 nike

我一直在关注 Kaa 提供的教程(谢谢!)和文档。我用java开发了一个kaa客户端,它运行完美并且已经部署。然而,它确实非常非常冗长。它对于调试和其他东西很有用,但现在它正在创建一个巨大的日志。有没有办法避免特定类和包的 INFO 消息 - 例如“org.kaaproject.kaa.client.channel.impl.*

最佳答案

要配置 kaa 日志的特定级别,您应该配置适当的日志架构文件。默认情况下它是logback.xml。例如,对于 Data Collection Demo 的 Java 源,日志架构为:JDataCollectionDemo/res/logback.xml要避免特定类或包的 INFO 消息,只需将具有错误级别的相应行添加到架构中,例如:

<logger name="org.kaaproject.kaa.client.channel.impl" level="ERROR"/>

在这种情况下,完整的日志架构将是:

    <?xml version="1.0" encoding="UTF-8" ?>
<!--

Copyright 2014-2016 CyberVision, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<appender name="fileLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>kaa-desktop-client.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="fileLogAppender"/>
</root>

<logger name="org.kaaproject.kaa" level="ERROR"/>
<logger name="org.kaaproject.kaa.client.logging.memory" level="INFO"/>
<logger name="org.kaaproject.kaa.demo.datacollection" level="INFO"/>
<logger name="org.kaaproject.kaa.client.channel.impl" level="ERROR"/>
</configuration>

还可以更改沙箱中日志的日志级别:对于 /var/log/kaa/kaa-node.log/var/log/kaa/kaa-sandbox.log,相应的日志架构文件是:/usr/lib/kaa-node/conf/logback.xml/usr/lib/kaa-sandbox/conf/logback.xml配置沙盒日志架构后,应重新启动相应的服务:

sudo service kaa-node restart
sudo service kaa-sandbox restart

关于java - 如何更改Kaa客户端的日志级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42118670/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com