![](/img/trans.png)
[英]How to analyze a .log file by using python and pandas to save into a data framework?
[英]How to save log file using Python?
我有一个 powershell 脚本,我使用这种方式保存日志
$Log = Start-Transcript -Path $Log_Path -Force
我如何在 Python 中使用它?
您可以使用以下命令写入/保存日志文件。
logging.basicConfig(filename='path to the log file', level=...)
有一个文件模式选项可以覆盖文件。 要覆盖,您可以指定 filemode:w
logging.basicConfig(filename='logs.log',
filemode='w',
level=logging.INFO)
filemode:指定打开文件的模式,如果指定了文件名(如果未指定文件模式,则默认为'a')。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.