log4c  1.2.4
Functions | Variables
appender_type_rollingfile.h File Reference

Log4c rolling file appender interface. More...

#include <log4c/defs.h>
#include <log4c/appender.h>
#include <log4c/rollingpolicy.h>
Include dependency graph for appender_type_rollingfile.h:

Go to the source code of this file.

Functions

rollingfile_udata_t * rollingfile_make_udata (void)
 
int rollingfile_udata_set_logdir (rollingfile_udata_t *rfudatap, const char *logdir)
 
int rollingfile_udata_set_files_prefix (rollingfile_udata_t *rfudatap, const char *prefix)
 
int rollingfile_udata_set_policy (rollingfile_udata_t *rfudatap, log4c_rollingpolicy_t *policyp)
 
const char * rollingfile_udata_get_logdir (rollingfile_udata_t *rfudatap)
 
const char * rollingfile_udata_get_files_prefix (rollingfile_udata_t *rfudatap)
 
long rollingfile_get_current_file_size (rollingfile_udata_t *rfudatap)
 

Variables

__LOG4C_BEGIN_DECLS const
log4c_appender_type_t 
log4c_appender_type_rollingfile
 

Detailed Description

Log4c rolling file appender interface.

The rolling file appender implements a logging mechanism of a list of files up to a maximum number.

The files are written by default to the current directory with logging names folowing the pattern log.1, log.2 etc. These parameters may be changed using the appropriate setter functions.

If the appender fails to open logfiles for writing then the messages are logged to stderr–it will continue to try to open the zero-th file for writing at rollover events so if it succeeds at some point to open that file the messages will start to appear therein and will no longer be sent to stderr.

Switching from logging from one file to the next is referred to as a 'rollover event'.

The policy that determines when a rollover event should happen is called a 'rolling policy'.

A mechanism is provided to allow different rolling policies to be defined.

Log4c ships with (and defaults to) the classic size-window rollover policy: this triggers rollover when files reach a maximum size. The first file in the list is always the current file; when a rollover event occurs files are shifted up by one position in the list–if the number of files in the list has already reached the max then the oldest file is rotated out of the window.

See the documentation in the rollingpolicy_type_sizewin.h file for more details on the size-win rollover policy.

Function Documentation

long rollingfile_get_current_file_size ( rollingfile_udata_t *  rfudatap)

Get the prefix string in this rolling file appender configuration.

Parameters
rfudatapthe rolling file appender configuration object.
Returns
the current size of the file being logged to.
rollingfile_udata_t* rollingfile_make_udata ( void  )

Get a new rolling file appender configuration object.

Returns
a new rolling file appender configuration object, otherwise NULL.
const char* rollingfile_udata_get_files_prefix ( rollingfile_udata_t *  rfudatap)

Get the prefix string in this rolling file appender configuration.

Parameters
rfudatapthe rolling file appender configuration object.
Returns
the prefix.
const char* rollingfile_udata_get_logdir ( rollingfile_udata_t *  rfudatap)

Get the logging directory in this rolling file appender configuration.

Parameters
rfudatapthe rolling file appender configuration object.
Returns
the logging directory.
int rollingfile_udata_set_files_prefix ( rollingfile_udata_t *  rfudatap,
const char *  prefix 
)

Set the prefix string in this rolling file appender configuration.

Parameters
rfudatapthe rolling file appender configuration object.
prefixthe logging files prfix to use.
Returns
zero if successful, non-zero otherwise.
int rollingfile_udata_set_logdir ( rollingfile_udata_t *  rfudatap,
const char *  logdir 
)

Set the logging directory in this rolling file appender configuration.

Parameters
rfudatapthe rolling file appender configuration object.
logdirthe logging directory to set.
Returns
zero if successful, non-zero otherwise.
int rollingfile_udata_set_policy ( rollingfile_udata_t *  rfudatap,
log4c_rollingpolicy_t policyp 
)

Set the rolling policy in this rolling file appender configuration.

Parameters
rfudatapthe rolling file appender configuration object.
policypthe logging files prfix to use.
Returns
zero if successful, non-zero otherwise.

Variable Documentation

__LOG4C_BEGIN_DECLS const log4c_appender_type_t log4c_appender_type_rollingfile

rollingfile appender type definition.

This should be used as a parameter to the log4c_appender_set_type() routine to set the type of the appender.