logo       

Re: activating options in file appender: msg#00001

Subject: Re: activating options in file appender

On Feb 1, 2007, at 3:31 PM, Mark Toohey wrote:

Hi,

I wrote some code which updates some fileAppenders after the files reach a certain size ( so once a file reaches x size it will be rolled over into an overflow file ). It was working fine when it was compiled as debug application (using VC6++ ). I compiled it as a release and this code is now causing me problems....specifically I believe when it tries to destruct the object and create a new one. Is there another way that I can change the current settings in
an appender?


Is there some reason that log4cxx::rolling::RollingFileAppender (the one defined in log4cxx/rolling/rollingfileappender.h, not the one in log4cxx/rollingfileappender.h) doesn't work for you? It allows pluggable triggering policies (the part that decides that it is time to roll) and rolling policies (the part that decides on file name). log4cxx::RollingFileAppender is a specific configuration of log4cxx::rolling::RFA to emulate org.apache.log4j.RollingFileAppender.

I'm not sure what the following code does. I'm just throwing off random observations.


LoggerPtr loggerRef = (LoggerPtr&)curLogger->loggerPtr;

Why do you need the cast? Actually, it would more efficient to use the copy constructor (instead of a default constructor and assignment):

LoggerPtr loggerRef(curLogger->loggerPtr);

DailyRollingFileAppenderPtr appender = loggerRef->getAppender ( cName );

This will throw an exception if the appender isn't a DRFA. DRFA is a specific configuration of log4cxx::rolling::RFA

cOption = convert_to_wchar_t( "file" );
cFile = convert_to_wchar_t( * curLogger->loggingModule->file );
appender->setOption( cOption , cFile );

logchar is typically UTF-8 char on Unixes and wchar_t on Windows (though that can be changed by configuration). I'm guessing this would not compile if logchar == UTF-8. Also, if you are going to the effort to cast to DRFA, then you should use setFile() instead of the generic setOption(). So either:

appender->setOption(LOG4CXX_STR("file"), curLogger->loggingModule- >file);

of just:

appender->setFile(curLogger->loggingModule->file);

Pool pool;

appender->activateOptions( pool );





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe