gpt4 book ai didi

symfony - Symnfy2 中 Monolog/Swiftmailer Html Formatter 的正确配置是什么?

转载 作者:行者123 更新时间:2023-12-04 08:25:42 25 4
gpt4 key购买 nike

我在设置 Monolog 以使用 Swiftmailer 和 Html 格式化程序时遇到问题。我有多个 Monolog 处理程序和 swiftmail 邮件程序,这可能是问题所在。这是我的 config.yml

独白部分:

services:
monolog.formatter.html:
class: Monolog\Formatter\HtmlFormatter


monolog:

channels: ["orders", "support"]

handlers:

# Called
orders:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%_orders.log"
level: info
channels: orders

# Called
support:
type: fingers_crossed
action_level: critical
handler: support_grouped
channels: support

# Not called, referenced in a handler [support]
support_grouped:
type: group
members: [support_log, environment_log, support_buffered]

# Not called, referenced in a group handler [grouped_support]
support_buffered:
type: buffer
handler: support_buffered_grouped

# Not called, referenced in a handler [support_buffered]
support_buffered_grouped:
type: group
members: [hipchat, webmaster_email, support_email]

# Not called, referenced in a group handler [support_buffered_grouped]
support_email:
type: swift_mailer
mailer: swiftmailer.mailer.errors
from_email: %webmaster_email_address%
to_email: %support_email_address%
subject: '[Costimator] Support: An Error Occurred!'
level: debug
content_type: text/html
formatter: monolog.formatter.html

# Called
webmaster:
type: fingers_crossed
action_level: critical
handler: webmaster_grouped

# Not called, referenced in a handler [webmaster]
webmaster_grouped:
type: group
members: [environment_log, webmaster_buffered]

# Not called, referenced in a handler [webmaster_grouped]
webmaster_buffered:
type: buffer
handler: webmaster_buffered_grouped

# Not called, referenced in a handler [webmaster_buffered_grouped]
webmaster_buffered_grouped:
type: group
members: [hipchat, webmaster_email]

# Not called, referenced in a group handler [webmaster_buffered_grouped, support_buffered_grouped]
webmaster_email:
type: swift_mailer
mailer: swiftmailer.mailer.errors
content_type: text/html
from_email: %webmaster_email_address%
to_email: %webmaster_email_address%
subject: '[Costimator] An Error Occurred!'
level: debug
formatter: monolog.formatter.html

# Not called, referenced in a group handler [support_grouped, webmaster_grouped]
environment_log:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug

# Not called, referenced in a group handler [support_grouped, webmaster_grouped]
support_log:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.support_log"
level: debug

# Not called, referenced in a group handler [webmaster_buffered_grouped, support_buffered_grouped]
hipchat:
type: hipchat
notify: true
token: xxx
room: xxx
level: critical

Swiftmailer 部分:
# Swiftmailer Configuration
swiftmailer:
default_mailer: %mailer_default_config%
mailers:
default:
delivery_address: "%mailer_delivery_address%"
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool:
type: "%mailer_spool_type%"
path: "%kernel.root_dir%/spool"

errors:
delivery_address: "%mailer_errors_delivery_address%"
transport: "%mailer_errors_transport%"
host: "%mailer_errors_host%"
username: "%mailer_errors_user%"
password: "%mailer_errors_password%"
spool:
type: "%mailer_errors_spool_type%"
path: "%kernel.root_dir%/spool"

错误以 text/html 形式发送,但没有表格格式。有任何想法吗?

//平@seldaek

编辑格式化程序似乎设置在处理程序上:

formatters set on handlers

最佳答案

上面的配置实际上可以正常工作。不知道发生了什么。

把这个留在这里给任何想要实现 HTML 格式的人。

关于symfony - Symnfy2 中 Monolog/Swiftmailer Html Formatter 的正确配置是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21949367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com