Apache log4cxx  Version 0.12.0
fileappender.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _LOG4CXX_FILE_APPENDER_H
19 #define _LOG4CXX_FILE_APPENDER_H
20 
21 #include <log4cxx/logger.h>
22 #include <log4cxx/logstring.h>
23 #include <log4cxx/writerappender.h>
24 #include <log4cxx/file.h>
25 #include <log4cxx/helpers/pool.h>
26 
27 #if defined(_MSC_VER)
28  #pragma warning ( push )
29  #pragma warning ( disable: 4251 )
30 #endif
31 
32 namespace log4cxx
33 {
34 namespace helpers
35 {
36 class Pool;
37 }
38 
46 class LOG4CXX_EXPORT FileAppender : public WriterAppender
47 {
48  protected:
56  bool fileAppend;
57 
61 
64  bool bufferedIO;
65 
69 
70  public:
76 
80  FileAppender();
81 
95  FileAppender(const LayoutPtr& layout, const LogString& filename, bool append,
96  bool bufferedIO, int bufferSize);
97 
107  FileAppender(const LayoutPtr& layout, const LogString& filename, bool append);
108 
115  FileAppender(const LayoutPtr& layout, const LogString& filename);
116 
117  ~FileAppender();
118 
128  virtual void setFile(const LogString& file);
129 
133  inline bool getAppend() const
134  {
135  return fileAppend;
136  }
137 
139  inline LogString getFile() const
140  {
141  return fileName;
142  }
143 
150  void activateOptions(log4cxx::helpers::Pool& p);
151  void setOption(const LogString& option,
152  const LogString& value);
153 
161  inline bool getBufferedIO() const
162  {
163  return bufferedIO;
164  }
165 
169  inline int getBufferSize() const
170  {
171  return bufferSize;
172  }
173 
184  void setAppend(bool fileAppend1);
185 
195  void setBufferedIO(bool bufferedIO);
196 
200  void setBufferSize(int bufferSize1)
201  {
202  this->bufferSize = bufferSize1;
203  }
204 
211  static LogString stripDuplicateBackslashes(const LogString& name);
212 
213  protected:
214  void activateOptionsInternal(log4cxx::helpers::Pool& p);
215 
236  void setFileInternal(const LogString& file, bool append,
237  bool bufferedIO, size_t bufferSize,
239 
240  void setFileInternal(const LogString& file);
241 
242  private:
243  FileAppender(const FileAppender&);
244  FileAppender& operator=(const FileAppender&);
245 
246 }; // class FileAppender
248 
249 } // namespace log4cxx
250 
251 #if defined(_MSC_VER)
252  #pragma warning (pop)
253 #endif
254 
255 #endif
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:148
bool fileAppend
Append to or truncate the file? The default value for this variable is true, meaning that by default ...
Definition: fileappender.h:56
bool getBufferedIO() const
Get the value of the BufferedIO option.
Definition: fileappender.h:161
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:142
LOG4CXX_PTR_DEF(AppenderAttachableImpl)
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:136
FileAppender appends log events to a file.
Definition: fileappender.h:46
int bufferSize
How big should the IO buffer be? Default is 8K.
Definition: fileappender.h:68
WriterAppender appends log events to a standard output stream.
Definition: writerappender.h:42
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:39
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:47
Definition: pool.h:32
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition: object.h:154
LogString fileName
The name of the log file.
Definition: fileappender.h:60
bool bufferedIO
Do we do bufferedIO?
Definition: fileappender.h:64
LogString getFile() const
Returns the value of the File option.
Definition: fileappender.h:139
void setBufferSize(int bufferSize1)
Set the size of the IO buffer.
Definition: fileappender.h:200
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66
int getBufferSize() const
Get the size of the IO buffer.
Definition: fileappender.h:169