LOG4C_APPENDER_TYPE_ROLLINGFILE(3)
π appender_type_rollingfile.h β Log4c rolling file appender interface π
okay bestie, gather round, because this is the log4c rolling file appender interface, and it's honestly kind of iconic. this page lives in the Library Functions Manual, and it's the whole tea on how log4c handles a rotating stack of log files. no cap, it's giving main character energy for your logging setup. β¨
β¨ NAME β¨
appender_type_rollingfile.h β the Log4c rolling file appender interface, periodt.
πΈ SYNOPSIS πΈ
#include <log4c/defs.h>
#include <log4c/appender.h>
#include <log4c/rollingpolicy.h>
π 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 π
so, the rolling file appender interface. here's the whole vibe:
the rolling file appender runs a logging mechanism that keeps a list of files, and that list has a max number it can hold. it's like a little shelf of log files and somebody keeps shoving new ones on. π«Ά
by default the files get written to the current directory, and the logging names follow the pattern log.1, log.2, etc. (yes, exactly that pattern, don't come for me). you can change all of that with the appropriate setter functions, because we love options. β¨
now here's the lowkey dramatic part: if the appender fails to open logfiles for writing, then the messages get logged to stderr β like, it's screaming into the void instead. and it will keep trying to open the zero-th file for writing at rollover events, so if at some point it finally succeeds in opening that file, the messages will start appearing in there and they will no longer be sent to stderr. glow up arc fr fr. π
switching from logging to one file to logging to the next one? that's called a 'rollover event'. remember that term, there will be a quiz. π
the policy that decides when a rollover event should happen is called a 'rolling policy'. and a mechanism is provided so you can define different rolling policies β mix and match, build your own, slay.
log4c ships with (and defaults to) the classic size-window rollover policy: it triggers a rollover when files reach a maximum size. the first file in the list is always the current file; when a rollover event happens, the files get shifted up by one position in the list β and if the number of files in the list has already hit the max, then the oldest file is rotated out of the window. bye bitch, you've been evicted. π
for more details on the size-win rollover policy, go read the documentation in the rollingpolicy_type_sizewin.h file. it's all there, iykyk.
π₯ Function Documentation π₯
π long rollingfile_get_current_file_size (rollingfile_udata_t * rfudatap)
get the prefix string in this rolling file appender configuration. (yes that's what the doc says, we just vibe with it π)
Parameters
rfudatapβ the 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. brand new, fresh out the box. π
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
rfudatapβ the 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
rfudatapβ the 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
rfudatapβ the rolling file appender configuration object.prefixβ the 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
rfudatapβ the rolling file appender configuration object.logdirβ the 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. this is the one that decides when the whole rollover situation goes down.
Parameters
rfudatapβ the rolling file appender configuration object.policypβ the logging files prfix to use. (ngl bestie, the original docs literally say "prfix" here β typo and all π β but what you're actually handing over is the rolling policy.)
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.
you should use this as a parameter to the log4c_appender_set_type() routine to set the type of the appender. that's literally the whole job. set the type, live your truth. β¨
π«Ά Author π«Ά
Generated automatically by Doxygen for log4c from the source code. (not a human, just a robot doing its little robot best π₯Ί)
and that's the page, bestie!! π this was log4c, Version 1.2.4, from the Library Functions Manual β appender_t...llingfile.h(3), mwah, obsessed, no notes. go forth and roll those files. ππ
β¨
π¦ where this page comes from
- epel 10: log4c-devel 1.2.4-32.el10_0 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: log4c-devel 1.2.4-34.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: log4c-devel 1.2.4-34.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: log4c-devel 1.2.4-35.fc44 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: log4c-devel 1.2.4-35.fc44 Β· LicenseRef-Callaway-LGPLv2+
- ubuntu stonking: liblog4c-doc 1.2.4-6
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms