log4cpp::FileAppender(3)

πŸ“¦
version 1.1.4 Β· 3 versions
, in opensuse-leap 16.0

πŸ’– 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 a FileAppender. we'll get into the details later, don't worry.
  • FileAppender(const std::string &name, int fd) β€” constructs a FileAppender to 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 the Layout for this appender.

πŸ¦‹ Public Member Functions inherited from log4cpp::AppenderSkeleton πŸ¦‹

  • virtual ~AppenderSkeleton() β€” destructor for AppenderSkeleton.
  • virtual void doAppend(const LoggingEvent &event) β€” log in Appender specific way.
  • virtual void setThreshold(Priority::Value priority) β€” set the threshold priority of this Appender.
  • virtual Priority::Value getThreshold() β€” get the threshold priority of this Appender.
  • virtual void setFilter(Filter *filter) β€” set a Filter for this appender.
  • virtual Filter *getFilter() β€” get the Filter for this appender.

🌈 Public Member Functions inherited from log4cpp::Appender 🌈

  • virtual ~Appender() β€” destructor for Appender.
  • const std::string &getName() const β€” get the name of this appender.

🧚 Protected Member Functions 🧚

  • virtual void _append(const LoggingEvent &event) β€” log in Appender specific 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 for AppenderSkeleton.

⭐ Protected Member Functions inherited from log4cpp::Appender ⭐

  • Appender(const std::string &name) β€” constructor for Appender.

πŸ“ 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 existing Appender. (the original says "exitsing", but we know what they mean, bestie 😭)
  • static bool reopenAll() β€” call reopen() on all existing Appenders.
  • static void closeAll() β€” call reopen() on all existing Appenders. (yes, the original says reopen() here too, not close(), 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 the Appender.
  • fileName β€” the name of the file to which the Appender has to log.
  • append β€” whether the Appender has 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 to 00644.

πŸ’– 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 the Appender.
  • fd β€” the file descriptor to which the Appender has 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 β€” The LoggingEvent to 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 β€” false to truncate, true to 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 by log4cpp Version 1.1, and the manpage name is log4cpp::FileAppender(3). slay. πŸ’…βœ¨πŸ¦‹πŸŒΈπŸ’–

okay that's the whole thing, bestie. go forth and log your little heart out. πŸ«ΆπŸ‘‘

πŸ“¦ where this page comes from