You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Roth Marcel <ma...@softlab.ch> on 2004/01/07 17:26:09 UTC

Log4J SMTP Appender Patternlayout no CR ?

Hello everybody,

I'm using the Log4J SMTP Appender, but the Email created in case of an error 
contains the Log-Statements without a Carriage-Return at the end of a Line. 
That makes the email quite unreadable ...

Is this normal behaviour of an SMTP Appender, 
or is there anything I could do about that ?

In the normal File/Console Appender I get readable statements with CR at the 
end.

Any infos appreciated ...

Regards,
Marcel Roth

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Log4J SMTP Appender Patternlayout no CR ?

Posted by Ceki Gülcü <ce...@qos.ch>.
My guess is that the email are generated on a Unix machine. Correct?

I am also guessing that you are using the PatternLayout for the
SMTPAppender. If so, note that %n results in \r on unix and \r\n on
windows. SMTP expects CRLF, that is is \r\n.

Having "\r\n" (not %n) at the end of the pattern for the layout used
by SMTPAppeder should do the trick.

Please let us know if the above does the trick,

At 05:26 PM 1/7/2004 +0100, Roth Marcel wrote:
>Hello everybody,
>
>I'm using the Log4J SMTP Appender, but the Email created in case of an error
>contains the Log-Statements without a Carriage-Return at the end of a Line.
>That makes the email quite unreadable ...
>
>Is this normal behaviour of an SMTP Appender,
>or is there anything I could do about that ?
>
>In the normal File/Console Appender I get readable statements with CR at the
>end.
>
>Any infos appreciated ...
>
>Regards,
>Marcel Roth

-- 
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp  



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Log4J SMTP Appender Patternlayout no CR ?

Posted by Ceki Gülcü <ce...@qos.ch>.
The results will depend on the originating system, that is the system 
generating the message (the machine where SMTPAppender executes), any 
intermediary servers and the email clients. Using "\r\n" should give the 
correct results on all types of originating machines, intermediary servers 
and software clients.

At 10:40 AM 1/8/2004 +0100, Roth Marcel wrote:
>Hi,
>
>I've done some further tests.
>
>Looks like that the difference is dependent on the Mailsystem/MailClient.
>With the Pattern "%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n" I got:
>
>- on MS Outlook 98: lines are displayed with CRLF (correct)
>- on MS Outlook 2000: lines are displayed without CRLF (wrong)
>
>At the moment I can live with that and use the workaround using ... \r\n in
>the pattern.
>
>cheers,
>Marcel
>
>Zitiere Ceki Gülcü <ce...@qos.ch>:
>
> >
> > Try "%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m\r\n" regardless of OS.
> >
> > SMTP assumes lines are ended with CRLF.
> >
> > At 06:21 PM 1/7/2004 +0100, Roth Marcel wrote:
> > >Hi,
> > >
> > >I'm using the following pattern:
> > >%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n
> > >
> > >Code looks like:
> > >
> > >String m_Pattern = "%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n";
> > >PatternLayout m_PLayout = null;
> > >
> > >m_PLayout = new PatternLayout(m_Pattern);
> > >
> > >SMTPAppender m_SMTP = new SMTPAppender();
> > >m_SMTP.setSMTPHost("SMTP_HOST");
> > >m_SMTP.setFrom("SMTP_FROM");
> > >m_SMTP.setTo("SMTP_TO");
> > >m_SMTP.setSubject("SMTP-Message: ");
> > >m_SMTP.setLayout(m_PLayout);
> > >m_SMTP.setBufferSize(2048);
> > >
> > >...
> > >
> > >I've tried already a workaround with adding a "\n" Newline at the end
> > of the
> > >pattern and that works fine then for the SMTP-Appender, but then I
> > cannot use
> > >this PatternLayout for the file appender ...
> > >
> > >what you think ?
> > >
> > >cheers,
> > >Marcel
> >
> > --
> > Ceki Gülcü
> >
> >       For log4j documentation consider "The complete log4j manual"
> >       ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
>
>
>
>Marcel Roth
>Technology Consultant
>Enterprise CRM
>_______________________________
>Softlab AG
>Kanalstrasse 31
>CH-8152 Glattbrugg
>Switzerland
>Telefon    +41 1 809 41 57
>Telefax    +41 1 809 41 42
>Mobile     +41 76 420 02 07
>E-Mail     mailto:marcel.roth@softlab.ch
>Homepage:  http://www.softlab.ch
>_______________________________
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org

-- 
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp  



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Log4J SMTP Appender Patternlayout no CR ?

Posted by Roth Marcel <ma...@softlab.ch>.
Hi,

I've done some further tests.

Looks like that the difference is dependent on the Mailsystem/MailClient.
With the Pattern "%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n" I got:

- on MS Outlook 98: lines are displayed with CRLF (correct)
- on MS Outlook 2000: lines are displayed without CRLF (wrong)

At the moment I can live with that and use the workaround using ... \r\n in 
the pattern.

cheers,
Marcel

Zitiere Ceki Gülcü <ce...@qos.ch>:

> 
> Try "%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m\r\n" regardless of OS.
> 
> SMTP assumes lines are ended with CRLF.
> 
> At 06:21 PM 1/7/2004 +0100, Roth Marcel wrote:
> >Hi,
> >
> >I'm using the following pattern:
> >%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n
> >
> >Code looks like:
> >
> >String m_Pattern = "%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n";
> >PatternLayout m_PLayout = null;
> >
> >m_PLayout = new PatternLayout(m_Pattern);
> >
> >SMTPAppender m_SMTP = new SMTPAppender();
> >m_SMTP.setSMTPHost("SMTP_HOST");
> >m_SMTP.setFrom("SMTP_FROM");
> >m_SMTP.setTo("SMTP_TO");
> >m_SMTP.setSubject("SMTP-Message: ");
> >m_SMTP.setLayout(m_PLayout);
> >m_SMTP.setBufferSize(2048);
> >
> >...
> >
> >I've tried already a workaround with adding a "\n" Newline at the end
> of the
> >pattern and that works fine then for the SMTP-Appender, but then I
> cannot use
> >this PatternLayout for the file appender ...
> >
> >what you think ?
> >
> >cheers,
> >Marcel
> 
> -- 
> Ceki Gülcü
> 
>       For log4j documentation consider "The complete log4j manual"
>       ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp  
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 



Marcel Roth
Technology Consultant
Enterprise CRM
_______________________________
Softlab AG
Kanalstrasse 31
CH-8152 Glattbrugg
Switzerland
Telefon    +41 1 809 41 57
Telefax    +41 1 809 41 42
Mobile 	   +41 76 420 02 07
E-Mail 	   mailto:marcel.roth@softlab.ch
Homepage:  http://www.softlab.ch
_______________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Log4J SMTP Appender Patternlayout no CR ?

Posted by Ceki Gülcü <ce...@qos.ch>.
Try "%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m\r\n" regardless of OS.

SMTP assumes lines are ended with CRLF.

At 06:21 PM 1/7/2004 +0100, Roth Marcel wrote:
>Hi,
>
>I'm using the following pattern:
>%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n
>
>Code looks like:
>
>String m_Pattern = "%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n";
>PatternLayout m_PLayout = null;
>
>m_PLayout = new PatternLayout(m_Pattern);
>
>SMTPAppender m_SMTP = new SMTPAppender();
>m_SMTP.setSMTPHost("SMTP_HOST");
>m_SMTP.setFrom("SMTP_FROM");
>m_SMTP.setTo("SMTP_TO");
>m_SMTP.setSubject("SMTP-Message: ");
>m_SMTP.setLayout(m_PLayout);
>m_SMTP.setBufferSize(2048);
>
>...
>
>I've tried already a workaround with adding a "\n" Newline at the end of the
>pattern and that works fine then for the SMTP-Appender, but then I cannot use
>this PatternLayout for the file appender ...
>
>what you think ?
>
>cheers,
>Marcel

-- 
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp  



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Log4J SMTP Appender Patternlayout no CR ?

Posted by Adrian Janssen <a....@videonetworks.com>.
Well I thought you might be missing the %n at the end, but its there. Sorry.

-----Original Message-----
From: Roth Marcel [mailto:marcel.roth@softlab.ch]
Sent: 07 January 2004 17:21
To: Log4J Users List; a.janssen@videonetworks.com
Subject: RE: Log4J SMTP Appender Patternlayout no CR ?


Hi,

I'm using the following pattern:
%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n

Code looks like:

String m_Pattern = "%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n";
PatternLayout m_PLayout = null;

m_PLayout = new PatternLayout(m_Pattern);

SMTPAppender m_SMTP = new SMTPAppender();
m_SMTP.setSMTPHost("SMTP_HOST");
m_SMTP.setFrom("SMTP_FROM");
m_SMTP.setTo("SMTP_TO");
m_SMTP.setSubject("SMTP-Message: ");
m_SMTP.setLayout(m_PLayout);
m_SMTP.setBufferSize(2048);

...

I've tried already a workaround with adding a "\n" Newline at the end of the
pattern and that works fine then for the SMTP-Appender, but then I cannot
use
this PatternLayout for the file appender ...

what you think ?

cheers,
Marcel


Zitiere Adrian Janssen <a....@videonetworks.com>:

> what pattern are you using?
>
> -----Original Message-----
> From: Roth Marcel [mailto:marcel.roth@softlab.ch]
> Sent: 07 January 2004 16:26
> To: 'Log4J Users List'
> Subject: Log4J SMTP Appender Patternlayout no CR ?
>
>
> Hello everybody,
>
> I'm using the Log4J SMTP Appender, but the Email created in case of an
> error
> contains the Log-Statements without a Carriage-Return at the end of a
> Line.
> That makes the email quite unreadable ...
>
> Is this normal behaviour of an SMTP Appender,
> or is there anything I could do about that ?
>
> In the normal File/Console Appender I get readable statements with CR at
> the
> end.
>
> Any infos appreciated ...
>
> Regards,
> Marcel Roth
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>



Marcel Roth
Technology Consultant
Enterprise CRM
_______________________________
Softlab AG
Kanalstrasse 31
CH-8152 Glattbrugg
Switzerland
Telefon    +41 1 809 41 57
Telefax    +41 1 809 41 42
Mobile 	   +41 76 420 02 07
E-Mail 	   mailto:marcel.roth@softlab.ch
Homepage:  http://www.softlab.ch
_______________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Log4J SMTP Appender Patternlayout no CR ?

Posted by Roth Marcel <ma...@softlab.ch>.
Hi,

I'm using the following pattern:
%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n

Code looks like:

String m_Pattern = "%d{yyyy-MM-dd HH:mm:ss} %-5p (%F:%L) - %m%n";  
PatternLayout m_PLayout = null;

m_PLayout = new PatternLayout(m_Pattern);

SMTPAppender m_SMTP = new SMTPAppender();
m_SMTP.setSMTPHost("SMTP_HOST");
m_SMTP.setFrom("SMTP_FROM");
m_SMTP.setTo("SMTP_TO");
m_SMTP.setSubject("SMTP-Message: ");
m_SMTP.setLayout(m_PLayout);
m_SMTP.setBufferSize(2048);

...

I've tried already a workaround with adding a "\n" Newline at the end of the 
pattern and that works fine then for the SMTP-Appender, but then I cannot use 
this PatternLayout for the file appender ...

what you think ?

cheers,
Marcel


Zitiere Adrian Janssen <a....@videonetworks.com>:

> what pattern are you using?
> 
> -----Original Message-----
> From: Roth Marcel [mailto:marcel.roth@softlab.ch]
> Sent: 07 January 2004 16:26
> To: 'Log4J Users List'
> Subject: Log4J SMTP Appender Patternlayout no CR ?
> 
> 
> Hello everybody,
> 
> I'm using the Log4J SMTP Appender, but the Email created in case of an
> error
> contains the Log-Statements without a Carriage-Return at the end of a
> Line.
> That makes the email quite unreadable ...
> 
> Is this normal behaviour of an SMTP Appender,
> or is there anything I could do about that ?
> 
> In the normal File/Console Appender I get readable statements with CR at
> the
> end.
> 
> Any infos appreciated ...
> 
> Regards,
> Marcel Roth
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 



Marcel Roth
Technology Consultant
Enterprise CRM
_______________________________
Softlab AG
Kanalstrasse 31
CH-8152 Glattbrugg
Switzerland
Telefon    +41 1 809 41 57
Telefax    +41 1 809 41 42
Mobile 	   +41 76 420 02 07
E-Mail 	   mailto:marcel.roth@softlab.ch
Homepage:  http://www.softlab.ch
_______________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Log4J SMTP Appender Patternlayout no CR ?

Posted by Adrian Janssen <a....@videonetworks.com>.
what pattern are you using?

-----Original Message-----
From: Roth Marcel [mailto:marcel.roth@softlab.ch]
Sent: 07 January 2004 16:26
To: 'Log4J Users List'
Subject: Log4J SMTP Appender Patternlayout no CR ?


Hello everybody,

I'm using the Log4J SMTP Appender, but the Email created in case of an error
contains the Log-Statements without a Carriage-Return at the end of a Line.
That makes the email quite unreadable ...

Is this normal behaviour of an SMTP Appender,
or is there anything I could do about that ?

In the normal File/Console Appender I get readable statements with CR at the
end.

Any infos appreciated ...

Regards,
Marcel Roth

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org