2009-03-05 6 views

Répondre

10

Ajouter quelque chose comme ceci à votre .log4crc fichier:

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

Ensuite, vous ne vous connecter comme d'habitude avec:

#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; 
} 

Tout cela est disponible dans les exemples des log4c source code

+1

Utile, merci, et bonne chance pour votre badge "neuromancien" ;-) – philant

+1

Voilà, vous allez mr necromancer. –

Questions connexes