Thanx Curt,
The appender class which I am going to create will only be used for
obtaining the logging string from the OStream *os variable(I have found out
only this mechanism by which I can get the logging string in my own
class....is there any other method for it).This logging string will be used
for some other purpose but not for logging.
I have tried to use "log4cxx::LayoutPtr layout(new
log4cxx::PatternLayout("%m %n\n"));" --But it is giving me an error that
PatternLayout is not defined in log4cxx.


Regards
Prosenjit Sinha


-----Original Message-----
From: Curt Arnold [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 07, 2004 12:34 AM
To: Log4CXX User
Subject: Custom appender (was Re: Building log4cxx 0.9.7 with MinGW and MSYS
(no cygwin))

Was this related to MinGW thread?  I didn't appear to be so I've
changed the subject.

First, let me warn you that there are major changes forthcoming in the
CVS that will significantly impact appenders.  I hope to have those
committed in the CVS within the week.

Without more details on the nature of the appender that you are
writing, it is hard to give any concrete suggestions.  I assume that it
is not something that would be general purpose that would be good to
discuss openly and have added to log4cxx.  If so, it would be better to
discuss it before getting down to implementation details.

Probably the best approach is to take ConsoleAppender (which derives
from WriterAppender) and start modifying it to include any needed
configuration.

On your LayoutPtr question, I you are trying to call
WriterAppender(LayoutPtr&, ostream*).  Most appenders do have
non-default constructors, but they are only used in unusual
circumstances.  In general, logging is configured from a configuration
file which will use the default constructor, call setOption to
configure the appender, then call activateOptions to get things ready
for use.  The likely best approach is to defer constructing your
ostream until the activateOptions method and then set the
WriterAppender::os variable.

As for your actual question, it is trivial to create a LayoutPtr;

log4cxx::LayoutPtr layout;  // initialized as a reference to null

or

log4cxx::LayoutPtr layout(new log4cxx::PatternLayout("%m %n\n"));


The implementation of appenders is intentionally similar to log4j.  You
may find it easier to do an initial implementation and experimentation
on log4j and then port your appender to log4cxx.



Confidentiality Notice

The information contained in this electronic message and any attachments to 
this message are intended
for the exclusive use of the addressee(s) and may contain confidential or 
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL 
PROTECTED] immediately
and destroy all copies of this message and any attachments.

Reply via email to