[logback-user] %file and %line not set when using SMTPAppender
Patrick Hogarty
hogartyp at gmail.com
Thu Aug 16 14:21:02 CEST 2012
Hello,
When using the SMTPAppender as such:
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>1.1.1.1</smtpHost>
<to>blah at blah</to>
<from>blah at blah</from>
<subject>TESTING: %logger{36} - %m</subject>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyyMMddHHmm:ss} %level [%thread] %logger{36}
[%file:%line] %msg%n</pattern>
</layout>
</appender>
The resulting log prints out like so:
201208161255:43 DEBUG [main] LoggingStuff.Foo [?:?] Did it again!
201208161255:43 INFO [main] LoggingStuff.Foo [?:?] Ha info - do it
201208161255:43 WARN [main] LoggingStuff.Foo [?:?] Something is about to
happen!
201208161255:43 ERROR [main] LoggingStuff.Foo [?:?] Serious stuff - is it?
java.lang.Exception: Yep
at LoggingStuff.Foo.doIt(Foo.java:56) [classes/:na]
at LoggingStuff.MyApp1.main(MyApp1.java:39) [classes/:na]
Where the %file and %line parameters are not set and show up as a '?'.
Using the ConsoleAppender and the FileAppender with the same pattern the
parameters all get set correctly, as such:
201208161247:54 DEBUG [main] LoggingStuff.Foo [Foo.java:53] Did it again!
201208161247:54 INFO [main] LoggingStuff.Foo [Foo.java:54] Ha info - do it
201208161247:54 WARN [main] LoggingStuff.Foo [Foo.java:55] Something is
about to happen!
201208161247:54 ERROR [main] LoggingStuff.Foo [Foo.java:56] Serious stuff -
is it?
java.lang.Exception: Yep
at LoggingStuff.Foo.doIt(Foo.java:56) [classes/:na]
at LoggingStuff.MyApp1.main(MyApp1.java:39) [classes/:na]
The one thing I have noticed, when looking at the sample code, is that for
both the File and Console appenders, the <pattern> tag is wrapped by an
<encoder> tag. Where as with the SMTP appender, the <pattern> tag is
wrapped by a <layout> tag.
Is there a way of forcing the SMTP appender to set these parameters?
Thank you
Patrick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120816/af2f391f/attachment.html>
More information about the Logback-user
mailing list