How to create an error on error_log / error_snapshot?

Hi there,

can’t find a way to log error on error_log / error_snapshot; i’m on develop branch, tried using:

frappe.log("FTPError({0}): {1} - Cannot connect to: {2}, retrying ...".format(e.errno, e.strerror, server))

but can’t get to work.

Any hint?

Thx in advance

from frappe.utils.error import make_error_snapshot

def try_something():
    try:
         1 / 0
    except Exception as e:
         make_error_snapshot(e)

The error will be stored in a file in the filesystem.
And will be collected by an async task

@max_morais_dmm Thx, not sure how long it will take to be collected from disk …but seems it is not working …

@JoEz, usually 5 minutes!
But depends of your async tasks running, and you can force the collection from console using:

from frappe.utils.error import collect_error_snapshot

collect_error_snapshot()
frappe.db.commit()

@max_morais_dmm thx, working