我一直在关注Kaa提供的教程(谢谢!)和文档。我用Java开发了一个kaa-client,它可以完美运行,并且已经部署。
但是,它确实非常冗长。这对于调试和填充非常有用,但是现在它正在创建一个巨大的日志。有没有一种方法可以避免针对特定类和包的INFO消息-例如“ org.kaaproject.kaa.client.channel.impl。*”

最佳答案

要为kaa日志配置特定级别,您应该配置适当的日志模式文件。默认情况下,它是logback.xml。
例如,对于数据收集演示的Java源,日志模式为:JDataCollectionDemo / res / logback.xml
为了避免针对特定类或包的INFO消息,只需将具有ERROR级别的相应行添加到架构中,例如:

<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/

10-10 14:51