From: ss ak <ss...@gm...> - 2009-08-24 21:12:37
|
I am writing into a file but does not append!! then one more big issue : While writing into file,it also puts on the console... how to set it to write into a file with out putting ont eh console... please..i need this to set it up asap... thanks |
From: Václav H. <v.h...@sh...> - 2009-08-24 21:17:22
Attachments:
signature.asc
|
ss ak wrote, On 24.8.2009 23:12: > I am writing into a file but does not append!! I have answered this in the previous email. > then one more big issue : While writing into file,it also puts on the > console... > > how to set it to write into a file with out putting ont eh console... > > please..i need this to set it up asap... Show the code and/or the properties file you are using. -- VH |
From: Václav H. <v.h...@sh...> - 2009-08-25 05:45:04
Attachments:
signature.asc
|
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 |
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 > > |
From: Václav H. <wi...@us...> - 2009-08-25 16:22:01
Attachments:
signature.asc
|
ss ak wrote, On 25.8.2009 18:19: > 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... Well, the documentation is not that good as it should be. If in doubt, look into the code :) > > how to set layout as Patternlayout??? What part of my example is not clear? > > 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); |
From: Václav H. <wi...@us...> - 2009-08-25 16:24:35
|
Václav Haisman wrote, On 25.8.2009 18:21: > ss ak wrote, On 25.8.2009 18:19: >> 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... > Well, the documentation is not that good as it should be. If in doubt, look > into the code :) > >> >> how to set layout as Patternlayout??? > What part of my example is not clear? Oh, I can see what you mean. Sorry. Try to take a look at the tests in tests directory. There is even a patternlayout_test. > >> >> 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); -- VH |