[logback-user] SMTPAppender Subject - Email found in subject - Email found in subject

Ceki Gulcu listid at qos.ch
Wed Aug 27 15:42:37 CEST 2008


The contents of the <subject> element is interpreted as a conversion pattern. 
The fact that in your initial report the conversion pattern contained only 
literals does not change that. The contents of the <pattern> element, as the 
name suggests, are also taken to be a conversion pattern.

You might want to read the chapter 5 on layouts, especially the section on the 
PaternLayout. http://logback.qos.ch/manual/layouts.html

 From what I could gather from your message, you probably want to change

<pattern>%ex</pattern>

to (at least)

<pattern>%m%n</pattern>

There many other conversion words you might want to use, such as %logger, %date, 
etc. It's all explained in chapter 5.

HTH,

alex wrote:
> Hi,
> I used your hint and now my conf is
> 
> <appender name="email" class="ch.qos.logback.classic.net.SMTPAppender">
>     <Subject>Error on resin1 - %p%nopex</Subject>
>     <Encoding>UTF-8</Encoding>
>     <SMTPHost>xxx.xxx.xx.xxx</SMTPHost>
>     <To>error at dnshosting.it</To>
>     <From>error at dnshosting.it</From>
>     <layout class="ch.qos.logback.classic.PatternLayout">
>       <pattern>%ex</pattern>
>     </layout>
>   </appender>
> 
> and now in the Subject is ok,  but I do not found the messagge error in 
> the body of email. I use in this casa in my java code
> log.error("Errore ServerVpeList for Grace not found for Ip xx.xx.xx.xxx");
> I use a FileAppender too and on file I found the Exception
>   ERROR xxxx.xxxx.xxxx.xxxxx - Errore ServerVpeList for Grace not found 
> for Ip xx.xx.xx.xxx
> Is the <pattern>%ex</pattern>  print ONLY the stack trace of exception ?
> How is possible to print in the email's body the message + stack trace ?
> 
> Thanks a lot for all
> 
> 
> 
> Lucas, Casey wrote:
>> Yes. When the exception is not in the subject, the mime problem goes away.
>>
>> -casey
>>
>> -----Original Message-----
>> From: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch] On Behalf Of Ceki Gulcu
>> Sent: Tuesday, August 26, 2008 2:28 PM
>> To: logback users list
>> Subject: [SPAM] - Re: [logback-user] [SPAM] - SMTPAppender Subject - Email found in subject - Email found in subject
>>
>>
>> Your suggestions circumvents a bug in the way SMTPAppender prepares its subject 
>> line. It works.
>>
>> However, the issue is why SMTPAppender's subject line contains an exception. 
>> I've created a bug report to deal with this issue.
>>
>>    http://jira.qos.ch/browse/LBCLASSIC-67
>>
>> Expect it to be fixed in the near future.
>>
>> As for the MIME format, is it related to the previous problem?
>>
>> Lucas, Casey wrote:
>>   
>>> IIRC, exceptions and email subjects don't jive.
>>> Try using %nopex as in:
>>>
>>> <Subject>Error on Application - %p%nopex</Subject>
>>>
>>> -casey
>>>
>>> -----Original Message-----
>>> From: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch]
>>> On Behalf Of alex
>>> Sent: Tuesday, August 26, 2008 8:24 AM
>>> To: logback-user at qos.ch
>>> Subject: [SPAM] - [logback-user] SMTPAppender Subject - Email found in
>>> subject
>>>
>>> Hi,
>>> I use this declaration in logback.xml with resin 3.1.6, logback 0.9.9, 
>>> and slf4j 1.5.2
>>>
>>> <configuration>
>>> <appender name="email" class="ch.qos.logback.classic.net.SMTPAppender">
>>>     <Subject>Error on Application</Subject>
>>>     <SMTPHost>localhost</SMTPHost>
>>>     <To>error at pippo.it</To>
>>>     <From>error at pippo.it</From>
>>>     <layout class="ch.qos.logback.classic.PatternLayout">
>>>       <pattern>%ex</pattern>
>>>     </layout>
>>>   </appender>
>>> <root>
>>>     <level value="error"/>
>>>     <appender-ref ref="email"/>
>>>   </root>
>>> </configuration>
>>>
>>> The emails for errors works but there are two problem :
>>>
>>> 1) In the Subject with my description is present all error message from 
>>> stacktrace like this
>>> Subject : Error on Application java.lang.NullPointerException    at 
>>> it.dnshst.action.log.LoginAction.doAction(LoginAction.java:74)    at 
>>> it.dnshst.action.BaseAction.runAction(BaseAction.java:221)  .....
>>>  How is possible to remove it (Stack trace) and only have my subjetc ?
>>> 2) In the body the of message there is a bad multi mime format like this
>>>
>>> at
>>>  
>>> com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:
>>> 164)
>>>
>>> 	at
>>>  
>>> com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.ja
>>> va:187)
>>>
>>> 	at
>>>  
>>> com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.j
>>> ava:266)
>>>
>>> 	at
>>> com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:270)
>>>
>>> 	at
>>> com.caucho.server.port.TcpConnection.run(TcpConnection.java:678)
>>> 	at
>>>  com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721)
>>> 	at
>>>  com.caucho.util.ThreadPool$Item.run(ThreadPool.java:643)
>>> 	at
>>>  java.lang.Thread.run(Thread.java:619)
>>> MIME-Version: 1.0
>>> Content-Type: multipart/mixed; 
>>> 	boundary="----=_Part_0_30676599.1219740931876"
>>>
>>> ------=_Part_0_30676599.1219740931876
>>> Content-Type: text/plain; charset=us-ascii
>>> Content-Transfer-Encoding: 7bit
>>>
>>> 2008-08-26 10:55:30,999 [http--8080-4] ERROR
>>> it.dnshst.servlet.MyDispatch - Error in Action for class
>>> it.dnshst.action.log.LoginAction
>>> java.lang.NullPointerException
>>> 	at
>>> it.dnshst.action.log.LoginAction.doAction(LoginAction.java:74)
>>> 	at it.dnshst.action.BaseAction.runAction(BaseAction.java:221)
>>> 	at it.dnshst.servlet.MyDispatch.doPost(MyDispatch.java:177)
>>> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:153)
>>> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
>>> 	at
>>> com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChai
>>> n.java:103)
>>> 	at
>>> com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:
>>> 164)
>>> 	at
>>> com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.ja
>>> va:187)
>>> 	at
>>> com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.j
>>> ava:266)
>>> 	at
>>> com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:270)
>>> 	at
>>> com.caucho.server.port.TcpConnection.run(TcpConnection.java:678)
>>> 	at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721)
>>> 	at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:643)
>>> 	at java.lang.Thread.run(Thread.java:619)
>>>
>>> -----=_Part_0_30676599.1219740931876--
>>>
>>> How is possible to have it correctly formatted ?
>>>
>>> Thanks a lot fro all help
>>> _______________________________________________
>>> Logback-user mailing list
>>> Logback-user at qos.ch
>>> http://qos.ch/mailman/listinfo/logback-user
>>> _______________________________________________
>>> Logback-user mailing list
>>> Logback-user at qos.ch
>>> http://qos.ch/mailman/listinfo/logback-user
>>>     
>>   
> 
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user

-- 
Ceki Gülcü


More information about the Logback-user mailing list