我的SMTPAppender主题在回溯访问中始终显示一个 将变量放在那里(模式)时%PARSER_ERROR。
对于主题行:
<subject>TESTING: %logger{20} - %m</subject>
我将此作为主题:
TESTING: %PARSER_ERROR[logger] - %PARSER_ERROR[m]
我在Jetty中使用1.0.13版本,我的logback-access.xml是 如下:
<appender name="SMTP"
class="ch.qos.logback.access.net.SMTPAppender">
<layout class="ch.qos.logback.access.PatternLayout">
<encoder>
<pattern>%fullRequest%n%n%fullResponse</pattern>
</encoder>
</layout>
<Evaluator class="ch.qos.logback.access.net.URLEvaluator">
<URL>index</URL>
</Evaluator>
<from>blahz@blah.com</from>
<subject>TESTING: %logger{20} - %m</subject>
<smtpHost>localhost</smtpHost>
<to>zzz@blah.com</to>
</appender>
<appender-ref ref="SMTP" />
当我完全省略 subject 标签时,我收到以下消息:
09:57:01,618 |-INFO in ch.qos.logback.access.net.SMTPAppender[SMTP] - About to send out SMTP message "%PARSER_ERROR[m]
" to [zzz@blah.com]
答案 0 :(得分:0)
试试这个:
<encoder>
<pattern>%fullRequest%n{}%n{}%fullResponse</pattern>
</encoder>
在Logback文档中引用:http://logback.qos.ch/manual/layouts.html#restrictionsOnLiterals