00001 /* 00002 * RollingFileAppender.hh 00003 * 00004 * See the COPYING file for the terms of usage and distribution. 00005 */ 00006 00007 #ifndef _LOG4CPP_ROLLINGFILEAPPENDER_HH 00008 #define _LOG4CPP_ROLLINGFILEAPPENDER_HH 00009 00010 #include <log4cpp/Portability.hh> 00011 #include <log4cpp/FileAppender.hh> 00012 #include <string> 00013 #include <stdarg.h> 00014 00015 LOG4CPP_NS_BEGIN 00016 00022 class LOG4CPP_EXPORT RollingFileAppender : public FileAppender { 00023 public: 00024 RollingFileAppender(const std::string& name, 00025 const std::string& fileName, 00026 size_t maxFileSize = 10 * 1024 * 1024, 00027 unsigned int maxBackupIndex = 1, 00028 bool append = true, 00029 mode_t mode = 00644); 00030 00031 virtual void setMaxBackupIndex(unsigned int maxBackups); 00032 virtual unsigned int getMaxBackupIndex() const; 00033 virtual void setMaximumFileSize(size_t maxFileSize); 00034 virtual size_t getMaxFileSize() const; 00035 00036 virtual void rollOver(); 00037 00038 protected: 00039 virtual void _append(const LoggingEvent& event); 00040 00041 unsigned int _maxBackupIndex; 00042 unsigned short int _maxBackupIndexWidth; // keep constant index width by zeroing leading positions 00043 00044 size_t _maxFileSize; 00045 private: 00046 // suppress assignment operator 00047 RollingFileAppender & operator=(const RollingFileAppender &); 00048 00049 }; 00050 LOG4CPP_NS_END 00051 00052 00053 #endif // _LOG4CPP_ROLLINGFILEAPPENDER_HH