logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Dahl <jdahl1...@yahoo.com>
Subject Re: Forward Declaration
Date Fri, 12 Sep 2008 21:05:49 GMT
Great. That is what I needed. Thanks a lot.

----- Original Message ----
From: Curt Arnold <carnold@apache.org>
To: Log4CXX User <log4cxx-user@logging.apache.org>
Sent: Friday, September 12, 2008 2:23:46 PM
Subject: Re: Forward Declaration

On Sep 12, 2008, at 12:00 PM, Jon Dahl wrote:

> Hello,
> I'm wondering if it is possible to use forward declaration with  
> log4cxx classes in a class header file. I would like to exclude the  
> log4cxx headers files in my header files if possible and include the  
> log4cxx header files in my cpp(source) files.
> Should this work?

No.  LoggerPtr is a template expansion and you'd need at least the  
template definition incorporate it in a header file.  However, you may  
want to consider not having a LoggerPtr in your class definition at  
all, but just have it in your implementation.  Something like:


#include <log4cxx/logger.h>

//  anonymous namespace, members are visible only in this compilation  
//   like static but better
namespace {
log4cxx::LoggerPtr logger(log4cxx::Logger::getRootLogger());

void Foo::someFunction() {
     LOG4CXX_INFO(logger, "Hello, World");

View raw message