Robbie Robinson | 3 Jul 19:36

How to apply layout to AsyncAppender?

I have a scenario where I want to use multiple appenders for the same logger (FileAppender and
SocketAppender for now).  Both appenders need to format the message using the same layout.  Instead of
formatting the single message multiple times(in the FileAppender and in the SocketAppender), I was
wanting to put both of these appenders under an AsyncAppender and apply the layout once in the
AsyncAppender, then send the formatted message to my sub-appenders.  What is the best way to accomplish
this?  From what I can tell the AsyncAppender does not support layouts.

Thanks,
Robbie

Scott Deboy | 3 Jul 19:41

RE: How to apply layout to AsyncAppender?

SocketAppender doesn't support a layout. 

log4j doesn't support the concept of inherited layouts, so you'll have to specify it for each appender that
needs one.

Scott Deboy
COMOTIV SYSTEMS
111 SW Columbia Street Ste. 950
Portland, OR  97201

Telephone:      503.224.7496
Cell:           503.997.1367
Fax:            503.222.0185

sdeboy <at> comotivsystems.com

www.comotivsystems.com

-----Original Message-----
From: Robbie Robinson [mailto:RobbieRobinson <at> m2-corp.com]
Sent: Thu 7/3/2008 10:40 AM
To: log4j-user <at> logging.apache.org
Subject: How to apply layout to AsyncAppender?

I have a scenario where I want to use multiple appenders for the same logger (FileAppender and
SocketAppender for now).  Both appenders need to format the message using the same layout.  Instead of
formatting the single message multiple times(in the FileAppender and in the SocketAppender), I was
wanting to put both of these appenders under an AsyncAppender and apply the layout once in the
AsyncAppender, then send the formatted message to my sub-appenders.  What is the best way to accomplish
this?  From what I can tell the AsyncAppender does not support layouts.
(Continue reading)

Robbie Robinson | 3 Jul 21:42

RE: How to apply layout to AsyncAppender?

I wasn't thinking so much about trying to have the layout inherited by the sub-appenders as much as apply the
layout and actually format the data at the AsyncAppender level.  That way I only spend the resources
formatting the data once (inside the AsyncAppender) instead of multiple times, once per sub-appender.

I realize the AsyncAppender does not support layouts, so I am looking for an alternative.  I ultimately want
to format/convert the log message into a custom XML format, but only do it once and deliver it to multiple appenders.

Thanks,
Robbie

-----Original Message-----
From: Scott Deboy [mailto:sdeboy <at> comotivsystems.com]
Sent: Thursday, July 03, 2008 1:42 PM
To: Log4J Users List
Subject: RE: How to apply layout to AsyncAppender?

SocketAppender doesn't support a layout.

log4j doesn't support the concept of inherited layouts, so you'll have to specify it for each appender that
needs one.

Scott Deboy
COMOTIV SYSTEMS
111 SW Columbia Street Ste. 950
Portland, OR  97201

Telephone:      503.224.7496
Cell:           503.997.1367
Fax:            503.222.0185

(Continue reading)


Gmane