[Log4c-devel] configuration file logging failure and log file reading
Brought to you by:
valtri
|
From: Reshmi K. <res...@ne...> - 2013-08-21 05:19:11
|
Hi all, I am trying to use log4c for my application logging. For implementing rolling policy, I used log4c rolling file APIs. I understood from Log4C developers guide that the rolling policy could be achieved by editing the configuration file (log4crc). I tried editing the appender name to a log file path in the configuration file. But the application run without logging. Can anyone please tell me how to implement rolling log mechanism using log4c <http://stackoverflow.com/questions/614193/how-to-use-rolling-log-using- log4c> ? Attached the helloworld application sample and the configuration file below: Hello world code snippet as follows: #include <stdio.h> #include "log4c.h" int main(int argc, char** argv){ int rc = 0; log4c_category_t* mycat = NULL; if (log4c_init()){ printf("log4c_init() failed"); rc = 1; }else{ mycat = log4c_category_get("log4c.examples.helloworld"); log4c_category_log(mycat, LOG4C_PRIORITY_ERROR, "Hello World!"); /* Explicitly call the log4c cleanup routine */ if ( log4c_fini()){ printf("log4c_fini() failed"); } } return 0; } The configuration file looks as follows: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE log4c SYSTEM ""> <log4c version="1.2.3"> <config> <bufsize>0</bufsize> <debug level="2"/> <nocleanup>0</nocleanup> <reread>1</reread> </config> <category name="root" priority="notice"/> <category name="six13log.log" priority="error" appender="stdout" /> <rollingpolicy name="myrollingpolicy" type="sizewin" maxsize="1024" maxnum="10" /> <appender name="myrollingfileappender" type="rollingfile" logdir="." prefix="myprefix" layout="dated" rollingpolicy="myrollingpolicy" /> <appender name="stdout" type="stream" layout="basic"/> <appender name="stderr" type="stream" layout="dated"/> <appender name="syslog" type="syslog" layout="basic"/> <appender name="s13file" type="s13_file" layout="basic"/> <appender name="plain_stderr" type="s13_stderr" layout="none"/> <appender name="cat_stderr" type="s13_stderr" layout="catlayout"/> <appender name="xml_stderr" type="s13_stderr" layout="xmllayout"/> <appender name="user_stderr" type="s13_stderr" layout="userlayout"/> <layout name="basic" type="basic"/> <layout name="dated" type="dated"/> <layout name="catlayout" type="s13_cat"/> <layout name="xmllayout" type="s13_xml"/> <layout name="none" type="s13_none"/> <layout name="userlayout" type="s13_userloc"/> <category name="six13log.log.app.application2" priority="debug" appender="cat_stderr" /> <category name="six13log.log.app.application3" priority="debug" appender="user_stderr" /> <category name="six13log.log.app" priority="debug" appender="myrollingfileappender" /> <category name="log4c.examples.helloworld" priority="debug" appender="stdout"/> <category name="log4c.examples.helloworld" priority="debug" appender="/home .. /..filename.txt"/> </log4c> I edited the last two lines in the configuration file for logging. Please let me know how the logging has done through the log4crc configuration file?? Also I want to know how the log file reading could be performed using log4c APIs?I tried with simple file operations to read the logs from a log file. But it fails. Thanks in advance Regards, Reshmi |