如何在 matlab 中进行日志记录:类似于 python 的日志记录

San*_*idi 2 python matlab logging

我是 matlab 新手:

我在 python 中工作,我通常使用大量日志记录来跟踪代码。在python中,我们可以使用下面的

import logging
logger = logging.getlogger()
logger.setLevel(logging.INFO)
handler = logging.FileHandler("log.txt",mode=w+)
handler.setlevel(loggin.INFO)
logger.addHandler(handler)

#And any where in the code use it as

logger.info("testing")

Run Code Online (Sandbox Code Playgroud)

我们如何在 matlab 中做类似的事情

And*_*nke 5

Matlab 中没有内置的日志记录功能。所以你需要使用第三方或未记录的工具。

Matlab随其捆绑的 JVM提供了 Java 日志记录库SLF4Jlog4j 。您可以将它们用于日志记录。有一个 Matlab SLF4M 库,为 SLF4J/log4j 提供了一层方便的 Matlab 绑定。(全面披露:我写了 SLF4M。)

MathWorks File Exchange 上还提供了一些本机 M 代码 Matlab 日志记录库: