[logback-user] Hostname in SMTPAppender subject

Mayes, Christopher Christopher.Mayes at cmegroup.com
Tue Sep 30 20:30:01 CEST 2008


Okay, I've gotten this working.  I should note that the hostname System property must be fed as a JVM argument (the blog post uses -Dhostname=`uname -n`).

I've noticed an odd issue with parentheses, though.  Including a closing paren (matched or not) truncates the rest of the format and pulls up the next line in the message.  So this format:

[CFG_SERVER] =${hostname}=  )  %logger{20} - %m %nopex

Gives the email subject:

[CFG_SERVER] =dv1035c=  java.io.FileNotFoundException: /tmp/cfg_server.data (Permission denied) at java.io.RandomAccessFile.open(Native Method)
<snipped remainder of stack>

Removing the closing paren:

[CFG_SERVER] =${hostname}=  %logger{20} - %m %nopex

Produces the expected output:

[CFG_SERVER] =dv1035c=  n.s.e.s.DiskStore - cfg_serverCache: Could not create disk store. Initial cause was /tmp/cfg_server.data (Permission denied)

What would cause this behavior?

Thanks,

-Chris

-----Original Message-----
From: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch] On Behalf Of Ceki Gulcu
Sent: Tuesday, September 30, 2008 4:40 AM
To: logback users list
Subject: Re: [logback-user] Hostname in SMTPAppender subject


Hello Chris,

It should work the same way. If it doesn't, it is a bug. If so, I would
appreciate if you could file a bug report at http://jira.qos.ch/

Regards,

Mayes, Christopher wrote:
> Hi, there.
>
> Is there a way to get the reporting machine's hostname into the subject of the SMTPAppender's email address?   According to a blog post, (http://blog.spiralarm.com/richard/2007/10/watching-production-logs.html) you can do something like this for log4j:
>
> <param name="Subject" value="[SMTPAppender] ${user.name}@${hostname} error message" />
>
> Is there a Logback equivalent?
>
> Thanks,
>
> -Chris

--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://qos.ch/mailman/listinfo/logback-user


More information about the Logback-user mailing list