Apache log4cxx  Version 0.11.0
fileappender.h
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 
60  LogString fileName;
61 
64  bool bufferedIO;
65 
69 
70  public:
71  DECLARE_LOG4CXX_OBJECT(FileAppender)
72  BEGIN_LOG4CXX_CAST_MAP()
73  LOG4CXX_CAST_ENTRY(FileAppender)
74  LOG4CXX_CAST_ENTRY_CHAIN(WriterAppender)
75  END_LOG4CXX_CAST_MAP()
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 
148  virtual void setFile(const LogString& file, bool append,
149  bool bufferedIO, size_t bufferSize,
150  log4cxx::helpers::Pool& p);
151 
155  inline bool getAppend() const
156  {
157  return fileAppend;
158  }
159 
161  inline LogString getFile() const
162  {
163  return fileName;
164  }
165 
172  void activateOptions(log4cxx::helpers::Pool& p);
173  void setOption(const LogString& option,
174  const LogString& value);
175 
183  inline bool getBufferedIO() const
184  {
185  return bufferedIO;
186  }
187 
191  inline int getBufferSize() const
192  {
193  return bufferSize;
194  }
195 
206  void setAppend(bool fileAppend1);
207 
217  void setBufferedIO(bool bufferedIO);
218 
222  void setBufferSize(int bufferSize1)
223  {
224  this->bufferSize = bufferSize1;
225  }
226 
233  static LogString stripDuplicateBackslashes(const LogString& name);
234 
235  private:
236  FileAppender(const FileAppender&);
237  FileAppender& operator=(const FileAppender&);
238 
239 }; // class FileAppender
240 LOG4CXX_PTR_DEF(FileAppender);
241 
242 } // namespace log4cxx
243 
244 #if defined(_MSC_VER)
245  #pragma warning (pop)
246 #endif
247 
248 #endif
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:183
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:40
Definition: pool.h:32
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:161
void setBufferSize(int bufferSize1)
Set the size of the IO buffer.
Definition: fileappender.h:222
Definition: appender.h:33
int getBufferSize() const
Get the size of the IO buffer.
Definition: fileappender.h:191