Apache Log4cxx  Version 1.7.0
Loading...
Searching...
No Matches
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>
24#include <log4cxx/file.h>
26
27namespace LOG4CXX_NS
28{
29namespace helpers
30{
31class Pool;
32}
33
44class LOG4CXX_EXPORT FileAppender : public WriterAppender
45{
46 protected:
47 struct FileAppenderPriv;
48
49 public:
55
56
60
74 FileAppender(const LayoutPtr& layout, const LogString& filename, bool append,
75 bool bufferedIO, int bufferSize);
76
86 FileAppender(const LayoutPtr& layout, const LogString& filename, bool append);
87
94 FileAppender(const LayoutPtr& layout, const LogString& filename);
95
97
107 virtual void setFile(const LogString& file);
108
112 bool getAppend() const;
113
116
128
148 void setOption(const LogString& option, const LogString& value) override;
149
156 bool getBufferedIO() const;
157
161 int getBufferSize() const;
162
168
181 void setAppend(bool newValue);
182
197 void setBufferedIO(bool newValue);
198
202 void setBufferSize(int newValue);
203
211 void setBufferedSeconds(int newValue);
212
220
221 protected:
223
243 void setFileInternal(const LogString& file, bool append,
244 bool bufferedIO, size_t bufferSize);
245
246 void setFileInternal(const LogString& file);
247
248#if LOG4CXX_ABI_VERSION <= 15
250 void setFileInternal(const LogString& file, bool append,
251 bool bufferedIO, size_t bufferSize,
252 helpers::Pool& p);
253#endif
254 private:
256 FileAppender& operator=(const FileAppender&);
257 protected:
258 FileAppender(std::unique_ptr<FileAppenderPriv> priv);
259
260}; // class FileAppender
262
263} // namespace log4cxx
264
265#endif
FileAppender appends log events to a file.
Definition fileappender.h:45
void setOption(const LogString &option, const LogString &value) override
Set option to value.
int getBufferSize() const
Get the size of the IO buffer.
void setAppend(bool newValue)
Set file open mode to newValue.
void setFileInternal(const LogString &file, bool append, bool bufferedIO, size_t bufferSize)
Sets and opens the file where the log output will go.
void setBufferedIO(bool newValue)
Set buffered output behavior to newValue.
LogString getFile() const
Returns the value of the File option.
void activateOptions(helpers::Pool &) override
static LogString stripDuplicateBackslashes(const LogString &name)
Replaces double backslashes with single backslashes for compatibility with paths from earlier XML con...
void activateOptionsInternal(helpers::Pool &1)
FileAppender()
The default constructor does not do anything.
FileAppender(std::unique_ptr< FileAppenderPriv > priv)
bool getBufferedIO() const
Get the value of the BufferedIO option.
void setFileInternal(const LogString &file, bool append, bool bufferedIO, size_t bufferSize, helpers::Pool &1)
int getBufferedSeconds() const
Get the number of seconds between file writes when the BufferedIO option is true.
void setBufferSize(int newValue)
Use newValue as the size of the output buffer.
bool getAppend() const
Returns the value of the Append option.
virtual void setFile(const LogString &file)
The File property takes a string value which should be the name of the file to append to.
void setBufferedSeconds(int newValue)
Flush the output buffer every newValue seconds.
void append(const spi::LoggingEventPtr &event, helpers::Pool &1) override
This method is called by the AppenderSkeleton::doAppend method.
WriterAppender()
This default constructor does nothing.
Definition pool.h:33
std::basic_string< logchar > LogString
Definition logstring.h:60
std::shared_ptr< Layout > LayoutPtr
Definition appender.h:42
LOG4CXX_PTR_DEF(Appender)
#define LOG4CXX_CAST_ENTRY(Interface)
Definition object.h:154
#define END_LOG4CXX_CAST_MAP()
Definition object.h:148
#define DECLARE_LOG4CXX_OBJECT(object)
Definition object.h:41
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)
Definition object.h:160
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:142
#define LOG4CXX_ACTIVATE_OPTIONS_FORMAL_PARAMETERS
Activate the options that were previously set with calls to option setters.
Definition optionhandler.h:53