Logging to a SMTPHandler #3784
Answered
by
luhn
mattiaverga
asked this question in
Q&A
Replies: 3 comments 1 reply
-
|
Cookiecutter uses stdlib’s logging config https://docs.python.org/3/howto/logging.html#configuring-logging
It looks like you need to use args and kwargs in your ini rather than directly setting mailhost et al. Something like:
[handler_smtp]
class = logging.handlers.SMTPHandler
level = ERROR
formatter = generic
kwargs = {‘mailhost’: ‘***’, ‘fromaddr’: ‘***’}
— Theron
… On Jun 18, 2025, at 9:56 AM, Mattia Verga ***@***.***> wrote:
I've followed the docs at https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html to configure logging with a StreamHandler handler to log message to the console.
I now want to add another handler to send errors to an email, so I've added this to the config.ini:
[handler_smtp]
class = logging.handlers.SMTPHandler
level = ERROR
formatter = generic
mailhost = ***
fromaddr = ***@***.org
toaddrs = ***@***.org
subject = server error
However it doesn't work:
TypeError: SMTPHandler.__init__() missing 4 required positional arguments: 'mailhost', 'fromaddr', 'toaddrs', and 'subject'
Does anyone have any idea how it is supposed to be configured?
—
Reply to this email directly, view it on GitHub <#3784>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAL7LRN4MROXM2M55PU2MBT3EGK3DAVCNFSM6AAAAAB7TVTLH6VHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZYGQ3DSMRYHE>.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mattiaverga
-
|
It's much jankier than that - the trick is to use the So basically: |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
thanks, I'll try |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've followed the docs at https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html to configure logging with a StreamHandler handler to log message to the console.
I now want to add another handler to send errors to an email, so I've added this to the config.ini:
However it doesn't work:
Does anyone have any idea how it is supposed to be configured?
Beta Was this translation helpful? Give feedback.
All reactions