log4c segmentation fault when calling rollingfile_udata_set_logdir

122 views Asked by At

This is my code:

const char *logdir = ".";
const char *rollingpolicy_name = "rpolicy";
rollingfile_udata_t *rfup = NULL;
log4c_appender_t* app    = NULL;
app = log4c_appender_get("rfileappender");
log4c_rollingpolicy_t *rollingpolicyp = NULL;
rfup = rollingfile_make_udata();
rollingfile_udata_set_logdir(rfup, logdir);

and this is the log4c4c file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4c SYSTEM "">

<log4c version="1.2.4">

    <config>
        <bufsize>0</bufsize>
        <debug level="2"/>
        <nocleanup>0</nocleanup>
        <reread>1</reread>
    </config>

    <category name="root" priority="notice"/>
<category name="log4c.collector" priority="debug" appender="rfileappender"/>
        <category name="six13log.log" priority="error" appender="stdout" />

        <rollingpolicy name="rpolicy" type="sizewin" maxsize="1024" maxnum="10" />


    <appender name="rfileappender" type="rollingfile" logdir="/var/log/" prefix="myprefixd" layout="dated" rollingpolicy="rpolicy" />

    <appender name="stdout" type="stream" layout="basic"/>
    <appender name="stderr" type="stream" layout="dated"/>

    <layout name="basic" type="basic"/>
    <layout name="dated" type="dated"/>

</log4c>

I get segmentation fault when calling rollingfile_udata_set_logdir(rfup, logdir);

1

There are 1 answers

0
Rony Tesler On BEST ANSWER

adding:

#include <log4c/category.h>
#include <log4c/appender.h>
#include <log4c/layout.h>
#include <log4c/appender_type_rollingfile.h>
#include <log4c/rollingpolicy.h>
#include <log4c/rollingpolicy_type_sizewin.h>

solved it.