简体   繁体   English

Deeplearning4j 禁用日志记录

[英]Deeplearning4j Disable Logging

I have a deeplearning for java project which is producing huge amounts of logger output on STDO.我有一个 Java 项目的深度学习,它在 STDO 上产生了大量的记录器输出。 I want to disable that but I cant seem to figure out how to do it.我想禁用它,但我似乎无法弄清楚如何去做。

I have a log4j.properties file in my src/main/resources folder which looks like this:我的 src/main/resources 文件夹中有一个log4j.properties文件,如下所示:

log4j.rootLogger=ERROR, Console
log4j.logger.play=WARN
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d{ABSOLUTE} %-5p ~ %m%n

log4j.appender.org.springframework=WARN
log4j.appender.org.nd4j=WARN
log4j.appender.org.canova=WARN
log4j.appender.org.datavec=WARN
log4j.appender.org.deeplearning4j=WARN
log4j.appender.opennlp.uima=OFF
log4j.appender.org.apache.uima=OFF
log4j.appender.org.cleartk=OFF

log4j.logger.org.springframework=WARN
log4j.logger.org.nd4j=WARN
log4j.logger.org.canova=WARN
log4j.logger.org.datavec=WARN
log4j.logger.org.deeplearning4j=WARN
log4j.logger.opennlp.uima.util=OFF
log4j.logger.org.apache.uima=OFF
log4j.logger.org.cleartk=OFF
log4j.logger.org.deeplearning4j.optimize.solvers.BaseOptimizer=OFF
slf4j.logger.org.deeplearning4j.optimize.solvers.BaseOptimizer=OFF

The specific output that is far too much is:太多的具体输出是:

21:26:34.860 [main] DEBUG odoptimize.solvers.BaseOptimizer - Hit termination condition on iteration 0: score=1.2894165074915344E19, oldScore=1.2894191699433697E19, condition=org.deeplearning4j.optimize.terminations.EpsTermination@55f111f3

which happens multiple times a second while training.这在训练时每秒发生多次。

The output of the log entry that you have provided look very much as the SLF4J output with Logback format (not LOG4J output).您提供的日志条目的输出看起来非常像Logback格式的 SLF4J 输出(不是 LOG4J 输出)。

Also dependencies of deeplearning4j-core advice SLF4J is used for logging.此外, deeplearning4j-core建议 SLF4J 的依赖项也用于日志记录。

Hence your log4j.properties have no effect on deeplearning4j logging.因此,您的log4j.properties对 deeplearning4j 日志记录没有影响。 Try to add logback.xml configuration to the resources as well and switch to WARN or ERROR level for root logger, see https://logback.qos.ch/manual/configuration.html尝试将logback.xml配置也添加到资源中,并切换到根记录器的 WARN 或 ERROR 级别,请参阅https://logback.qos.ch/manual/configuration.html

There are some properties in the framework DL4J (1.0.0-beta7) that activate/deactivate the logs.框架 DL4J (1.0.0-beta7) 中有一些属性可以激活/停用日志。 I found some of them:我找到了其中一些:

import org.nd4j.common.config.ND4JSystemProperties;

System.setProperty(ND4JSystemProperties.LOG_INITIALIZATION, "false");
System.setProperty(ND4JSystemProperties.ND4J_IGNORE_AVX, "true");
System.setProperty(ND4JSystemProperties.VERSION_CHECK_PROPERTY, "false");

Notice that this is an unconventional solution.请注意,这是一个非常规的解决方案。 On the other hand, there are some messages impossible to avoid:另一方面,有一些信息是无法避免的:

MultiLayerNetwork.init()

In this method you can find a OneTimeLogger without validations:在这个方法中,你可以找到一个没有验证的 OneTimeLogger:

    OneTimeLogger.info(log, "Starting MultiLayerNetwork with WorkspaceModes set to [training: {}; inference: {}], cacheMode set to [{}]",
            layerWiseConfigurations.getTrainingWorkspaceMode(),
            layerWiseConfigurations.getInferenceWorkspaceMode(),
            layerWiseConfigurations.getCacheMode());

If you find a better way to disable log messages inside DL4J please share it.如果您找到在 DL4J 中禁用日志消息的更好方法,请分享。 There are some other ways outside the DL4J library.在 DL4J 库之外还有其他一些方法。

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

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