You are here: Hello » blog » Log Micropython console text to file

Log Micropython console text to file

Here is a small snippet, how you can write everything what you get on console to file in your Micropython device. This may help you to debug long running devices.

import io, os
class logToFile(io.IOBase):
    def __init__(self):
    def write(self, data):
        with open("logfile.txt", mode="a") as f:
        return len(data)
# now your console text output is saved into file
# disable logging to file


Enter your comment:
P W G᠎ H W
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported - Nemokamas lankytojų skaitliukas XHTML