8 #ifdef LOG4CPP_HAVE_IO_H 11 #ifdef LOG4CPP_HAVE_UNISTD_H 15 #include <sys/types.h> 25 #ifdef LOG4CPP_HAVE_SSTREAM 33 const std::string& fileName,
35 unsigned int maxBackupIndex,
39 _maxBackupIndex(maxBackupIndex > 0 ? maxBackupIndex : 1),
40 _maxBackupIndexWidth((_maxBackupIndex > 0) ? log10((float)_maxBackupIndex)+1 : 1),
41 _maxFileSize(maxFileSize) {
67 std::string last_log_filename = filename_stream.
str();
68 std::cout << last_log_filename << std::endl;
69 ::remove(last_log_filename.c_str());
73 filename_stream.
str(std::string());
75 ::rename(filename_stream.
str().c_str(), last_log_filename.c_str());
76 last_log_filename = filename_stream.
str();
79 ::rename(
_fileName.c_str(), last_log_filename.c_str());
86 off_t offset = ::lseek(
_fd, 0, SEEK_END);
98 std::string name, filename;
101 int max_file_size = 0, max_backup_index = 0;
102 params.
get_for(
"roll file appender").
required(
"name", name)(
"filename", filename)(
"max_file_size", max_file_size)
103 (
"max_backup_index", max_backup_index)
104 .optional(
"append", append)(
"mode", mode);
106 return std::auto_ptr<Appender>(
new RollingFileAppender(name, filename, max_file_size, max_backup_index, append, mode));
const std::string _fileName
unsigned int _maxBackupIndex
virtual size_t getMaxFileSize() const
required_params_validator required(const char *param, T &value) const
virtual void _append(const LoggingEvent &event)
virtual void _append(const LoggingEvent &event)
RollingFileAppender(const std::string &name, const std::string &fileName, size_t maxFileSize=10 *1024 *1024, unsigned int maxBackupIndex=1, bool append=true, mode_t mode=00644)
std::auto_ptr< Appender > create_roll_file_appender(const FactoryParams &)
virtual void setMaxBackupIndex(unsigned int maxBackups)
unsigned short int _maxBackupIndexWidth
virtual unsigned int getMaxBackupIndex() const
details::parameter_validator get_for(const char *tag) const
virtual void setMaximumFileSize(size_t maxFileSize)