Vogon Jeltz
Vogon Jeltz

Reputation: 1315

Deeplearning4j Disable Logging

I have a deeplearning for java project which is producing huge amounts of logger output on 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:

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 o.d.optimize.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.

Upvotes: 0

Views: 1243

Answers (2)

Uriel Herrera
Uriel Herrera

Reputation: 53

There are some properties in the framework DL4J (1.0.0-beta7) that activate/deactivate the logs. 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.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. There are some other ways outside the DL4J library.

Upvotes: 1

Vladimir L.
Vladimir L.

Reputation: 1126

The output of the log entry that you have provided look very much as the SLF4J output with Logback format (not LOG4J output).

Also dependencies of deeplearning4j-core advice SLF4J is used for logging.

Hence your log4j.properties have no effect on deeplearning4j logging. 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

Upvotes: 3

Related Questions