log4c does not work in service mode

231 views Asked by At

I'm new to linux C programming

And I am trying to write a service runnig on a CentOS host, log4c works as my logging module.

Everything works just fine during developing and debbugging, but when I finally install and run it as a service, no logs were ever created. But if I start it via shell, the logging seems perfect.

The script starting the service is simply:

daemon MyService -c 0

Starting by typing

./Myservice -c 0

and the logs show up

Please help, did I get anything wrong anywhere?

Oh, following are relative codes:

//----------------------wrapper.h------------------

#define SL_LOG_TRACE(cat, fmt, args...) { \
const log4c_location_info_t locinfo = LOG4C_LOCATION_INFO_INITIALIZER(NULL); \
log4c_category_log_locinfo(cat, &locinfo, LOG4C_PRIORITY_TRACE, fmt, ##args); }\

//----------------------main.c----------------------

void SomeFunc() 
{
    ...
    SL_LOG_TRACE(g_cat, "some logs");
    ...

//----------------log4c resource--------------

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE log4c SYSTEM "">
<log4c version="1.2.1">
    <config>
        <bufsize>0</bufsize>
        <debug level="2"/>
        <nocleanup>0</nocleanup>
        <reread>1</reread>
    </config>

    <category name="FileLogger" priority="trace" appender="myrollingfileappender"/>

    <appender name="myrollingfileappender" type="rollingfile" logdir="." prefix="sl_log" layout="dated" rollingpolicy="myrollingpolicy"/>
    <rollingpolicy name="myrollingpolicy" type="sizewin" maxsize="102400" maxnum="10"/>

//------------------LOG4C_RCPATH="/somedir/log"---------------------

0

There are 0 answers