log4cpp::FileAppender(3)
π log4cpp::FileAppender(3) π
okay bestie, so this is the manual page for log4cpp::FileAppender from the log4cpp library (Version 1.1, she's iconic). It's literally the file appender class and it's giving main character energy for all your logging needs. Let me break it down for you, no cap. β¨
πΈ SYNOPSIS πΈ
#include <FileAppender.hh>
okay so first things first: it inherits from log4cpp::LayoutAppender. and guess what? it's also inherited by log4cpp::DailyRollingFileAppender and log4cpp::RollingFileAppender. the family tree is thriving, we love to see it. π³
π Public Member Functions π
FileAppender(const std::string &name, const std::string &fileName, bool append=true, mode_t mode=00644)β constructs aFileAppender. we'll get into the details later, don't worry.FileAppender(const std::string &name, int fd)β constructs aFileAppenderto an already open file descriptor. fancy.virtual ~FileAppender()β the destructor, she cleans up.virtual bool reopen()β reopens the logfile. super useful for external rotation, iykyk.virtual void close()β closes the logfile. bye bestie.virtual void setAppend(bool append)β sets the append vs truncate flag. (spoiler: it's a little late for the first open, more on that below)virtual bool getAppend() constβ gets the value of the'append'option.virtual void setMode(mode_t mode)β sets the file open mode.virtual mode_t getMode() constβ gets the file open mode.
π Public Member Functions inherited from log4cpp::LayoutAppender π
LayoutAppender(const std::string &name)β constructor.virtual ~LayoutAppender()β destructor.virtual bool requiresLayout() constβ check if the appender requires a layout.virtual void setLayout(Layout *layout=NULL)β set theLayoutfor this appender.
π¦ Public Member Functions inherited from log4cpp::AppenderSkeleton π¦
virtual ~AppenderSkeleton()β destructor forAppenderSkeleton.virtual void doAppend(const LoggingEvent &event)β log inAppenderspecific way.virtual void setThreshold(Priority::Value priority)β set the threshold priority of thisAppender.virtual Priority::Value getThreshold()β get the threshold priority of thisAppender.virtual void setFilter(Filter *filter)β set aFilterfor this appender.virtual Filter *getFilter()β get theFilterfor this appender.
π Public Member Functions inherited from log4cpp::Appender π
virtual ~Appender()β destructor forAppender.const std::string &getName() constβ get the name of this appender.
π§ Protected Member Functions π§
virtual void _append(const LoggingEvent &event)β log inAppenderspecific way. this is the one subclasses override.
β¨ Protected Member Functions inherited from log4cpp::LayoutAppender β¨
Layout &_getLayout()β return the layout of the appender.
π« Protected Member Functions inherited from log4cpp::AppenderSkeleton π«
AppenderSkeleton(const std::string &name)β constructor forAppenderSkeleton.
β Protected Member Functions inherited from log4cpp::Appender β
Appender(const std::string &name)β constructor forAppender.
π Protected Attributes π
const std::string _fileNameβ protected, she's the file name.int _fdβ protected, the file descriptor.int _flagsβ protected, the flags.mode_t _modeβ protected, the mode.
π Additional Inherited Members π
πΈ Public Types inherited from log4cpp::LayoutAppender πΈ
typedef BasicLayout DefaultLayoutTypeβ the default layout type, periodt.
π
Static Public Member Functions inherited from log4cpp::Appender π
static Appender *getAppender(const std::string &name)β get a pointer to an existingAppender. (the original says "exitsing", but we know what they mean, bestie π)static bool reopenAll()β callreopen()on all existingAppenders.static void closeAll()β callreopen()on all existingAppenders. (yes, the original saysreopen()here too, notclose(), so I'm keeping it exactly as writtenβdon't come for me π)
π Constructor & Destructor Documentation π
π log4cpp::FileAppender::FileAppender(const std::string &name, const std::string &fileName, bool append = true, mode_t mode = 00644) π
Constructs a FileAppender. literally creating the whole vibe.
Parameters:
nameβ the name of theAppender.fileNameβ the name of the file to which theAppenderhas to log.appendβ whether theAppenderhas to truncate the file or just append to it if it already exists. Defaults to'true'.modeβ file mode to open the logfile with. Defaults to00644.
π log4cpp::FileAppender::FileAppender(const std::string &name, int fd) π
Constructs a FileAppender to an already open file descriptor. so you're bringing your own fd, okay queen.
Parameters:
nameβ the name of theAppender.fdβ the file descriptor to which theAppenderhas to log.
π log4cpp::FileAppender::~FileAppender() [virtual] π
the destructor. she's virtual and she's doing her thing.
π₯ Member Function Documentation π₯
π void log4cpp::FileAppender::_append(const LoggingEvent &event) [protected], [virtual] π
Log in Appender specific way. Subclasses of Appender should implement this method to perform actual logging. it's the behind-the-scenes queen.
Parameters:
eventβ TheLoggingEventto log.
Implements: log4cpp::AppenderSkeleton.
Reimplemented in: log4cpp::DailyRollingFileAppender, and log4cpp::RollingFileAppender. the whole squad is on it.
π void log4cpp::FileAppender::close() [virtual] π
Closes the logfile. simple as that.
Implements: log4cpp::AppenderSkeleton.
π bool log4cpp::FileAppender::getAppend() const [virtual] π
Gets the value of the 'append' option. just a little getter, no drama.
π mode_t log4cpp::FileAppender::getMode() const [virtual] π
Gets the file open mode. yup, that's it.
π bool log4cpp::FileAppender::reopen() [virtual] π
Reopens the logfile. This can be useful for logfiles that are rotated externally, e.g. by logrotate. This method is a NOOP for FileAppenders that have been constructed with a file descriptor. (so if you used the fd constructor, reopen() does literally nothingβdon't @ me, that's what the manpage says.)
Returns: true if the reopen succeeded.
Reimplemented from: log4cpp::AppenderSkeleton.
π void log4cpp::FileAppender::setAppend(bool append) [virtual] π
Sets the append vs truncate flag. NB. currently the FileAppender opens the logfile in the constructor. Therefore this method is too late to influence the first file opening. We'll need something similar to log4j's activateOptions(). (so like, it works but not for the first openβimportant caveat, bestie.)
Parameters:
appendβfalseto truncate,trueto append
π void log4cpp::FileAppender::setMode(mode_t mode) [virtual] π
Sets the file open mode. that's the whole thing.
π Member Data Documentation π
int log4cpp::FileAppender::_fd [protected]β the file descriptor, protected.const std::string log4cpp::FileAppender::_fileName [protected]β the file name, protected and const.int log4cpp::FileAppender::_flags [protected]β the flags, protected.mode_t log4cpp::FileAppender::_mode [protected]β the mode, protected.
π Author π
Generated automatically by Doxygen for log4cpp from the source code. (so you can thank Doxygen for this masterpiece, no cap.)
this page is brought to you bylog4cppVersion 1.1, and the manpage name islog4cpp::FileAppender(3). slay. π β¨π¦πΈπ
okay that's the whole thing, bestie. go forth and log your little heart out. π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: log4cpp-devel 1.1.4-bp160.1.12 Β· LGPL-2.1-only
- opensuse-leap 16.0: log4cpp-devel 1.1.4-bp160.1.12 Β· LGPL-2.1-only
- opensuse-leap 16.0: log4cpp-devel 1.1.4-bp160.1.12 Β· LGPL-2.1-only
- opensuse-leap 16.0: log4cpp-devel 1.1.4-bp160.1.12 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms