|
From: ss ak <ss...@gm...> - 2009-08-25 16:19:51
|
where do i find the list of properties to set????
in the documentation or in the code..i could not find what properties to
set...
how to set layout as Patternlayout???
log4cplus::BasicConfigurator config;config.configure();
logger = Logger::getInstance("main");
log4cplus::helpers::Properties props;
props.setProperty (LOG4CPLUS_TEXT ("Append"), LOG4CPLUS_TEXT ("true"));
props.setProperty (LOG4CPLUS_TEXT ("File"), LOG4CPLUS_TEXT ("logfile.log"));
props.setProperty (LOG4CPLUS_TEXT ("PatternLayout"),LOG4CPLUS_TEXT ("%c"));
log4cplus::Layout pattlayout = new log4cplus::PatternLayout(props);
log4cplus::SharedAppenderPtr fileapp (new log4cplus::FileAppender (props));
logger.addAppender(fileapp);
logger.setLogLevel(log4cplus::DEBUG_LOG_LEVEL);
2009/8/24 Václav Haisman <v.h...@sh...>
> ss ak wrote, On 25.8.2009 1:15:
> > How do i set
> > Append=true.
> >
> > I didnt find any properties to set on the fileappender....
> > this is the only code i am using...
> >
> >> here is the code
> >> log4cplus::BasicConfigurator config;
> >>
> >> config.configure();
> >>
> >> log4cplus::Logger logger = Logger::getInstance("main");
> >>
> >> log4cplus::SharedAppenderPtr
> > fileapp(new log4cplus::FileAppender("logfile.log"));
> >>
> >> logger.addAppender(fileapp);
> >>
> >> logger.setLogLevel(log4cplus::DEBUG_LOG_LEVEL);
> > It outputs on the console too...
> I did not realise it before, yes, it does output to console. That is
> because
> BasicConfigurator automatically adds ConsoleAppender to rootLogger. If you
> want to avoid that, use PropertyConfigurator instead.
>
> To make the FileAppender append to existing file, configure it with the
> Append=true property. Something like this:
>
> log4cplus::helpers::Properties props;
> props.setProperty (LOG4CPLUS_TEXT ("Append"), LOG4CPLUS_TEXT ("true"));
> props.setProperty (LOG4CPLUS_TEXT ("File"), LOG4CPLUS_TEXT
> ("logfile.log"));
> log4cplus::SharedAppenderPtr fileapp (new log4cplus::FileAppender (props));
>
> --
> VH
>
>
|