I am using the breeze.optimize
package of Scala Breeze, and it looks like Breeze ahs implemented its own logging library.
Is there a way to configure Breeze to use standard logging like log4j or slf4j so I can configure logging for optimizations the same way I do for everything else in my application?
Alternatively, how do I just turn off the logging messages. They are on by defaults and logging every iteration of a function minimization for me, which is generating a lot of log noise for me.
Wrapper for Apache Commons based ont he answer below:
import breeze.util.logging.Logger
import breeze.util.logging.Logger.Level
import org.apache.commons.logging.LogFactory
class BreezeCommonsLogger[T: ClassManifest] extends Logger {
private val log = LogFactory.getLog(classManifest[T].erasure)
def trace(f: => Any) { if (log.isTraceEnabled()) log.trace(f.toString) }
def debug(f: => Any) { if (log.isDebugEnabled()) log.debug(f.toString) }
def info(f: => Any) { if (log.isInfoEnabled()) log.info(f.toString) }
def warn(f: => Any) { if (log.isWarnEnabled()) log.warn(f.toString) }
def error(f: => Any) { if (log.isErrorEnabled()) log.error(f.toString) }
def fatal(f: => Any) { if (log.isFatalEnabled()) log.fatal(f.toString) }
def level_=(level: Level) {}
def level = Logger.NEVER
}
I was able to use this like:
val lbfgs = new LBFGS[Mat](maxIters, 5, tolerance) {
override val log = new BreezeCommonsLogger[LBFGS[Mat]]
}