source: pacpusframework/branches/0.1.x/3rd/apache-log4cxx/include/log4cxx/dailyrollingfileappender.h@ 210

Last change on this file since 210 was 89, checked in by morasjul, 12 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 6.3 KB
Line 
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_DAILYROLLINGFILEAPPENDER_H
19#define _LOG4CXX_DAILYROLLINGFILEAPPENDER_H
20
21#if defined(_MSC_VER)
22#pragma warning ( push )
23#pragma warning ( disable: 4231 4251 4275 4786 )
24#endif
25
26
27#include <log4cxx/appender.h>
28#include <log4cxx/fileappender.h>
29#include <log4cxx/spi/optionhandler.h>
30#include <log4cxx/rolling/rollingfileappenderskeleton.h>
31
32namespace log4cxx {
33 namespace helpers {
34 class Pool;
35 }
36
37 namespace spi {
38 class ErrorHandler;
39 typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
40 }
41
42
43/**
44 DailyRollingFileAppender extends {@link log4cxx::FileAppender FileAppender} so that the
45 underlying file is rolled over at a user chosen frequency.
46
47 <p>The rolling schedule is specified by the <b>DatePattern</b>
48 option. This pattern should follow the
49 {@link log4cxx::helpers::SimpleDateFormat SimpleDateFormat}
50 conventions. In particular, you <em>must</em> escape literal text
51 within a pair of single quotes. A formatted version of the date
52 pattern is used as the suffix for the rolled file name.
53
54 <p>For example, if the <b>File</b> option is set to
55 <code>/foo/bar.log</code> and the <b>DatePattern</b> set to
56 <code>'.'yyyy-MM-dd</code>, on 2001-02-16 at midnight, the logging
57 file <code>/foo/bar.log</code> will be copied to
58 <code>/foo/bar.log.2001-02-16</code> and logging for 2001-02-17
59 will continue in <code>/foo/bar.log</code> until it rolls over
60 the next day.
61
62 <p>Is is possible to specify monthly, weekly, half-daily, daily,
63 hourly, or minutely rollover schedules.
64
65 <p><table border="1" cellpadding="2">
66 <tr>
67 <th>DatePattern</th>
68 <th>Rollover schedule</th>
69 <th>Example</th>
70
71 <tr>
72 <td><code>'.'yyyy-MM</code>
73 <td>Rollover at the beginning of each month</td>
74
75 <td>At midnight of May 31st, 2002 <code>/foo/bar.log</code> will be
76 copied to <code>/foo/bar.log.2002-05</code>. Logging for the month
77 of June will be output to <code>/foo/bar.log</code> until it is
78 also rolled over the next month.
79
80 <tr>
81 <td><code>'.'yyyy-ww</code>
82
83 <td>Rollover at the first day of each week. The first day of the
84 week depends on the locale.</td>
85
86 <td>Assuming the first day of the week is Sunday, on Saturday
87 midnight, June 9th 2002, the file <i>/foo/bar.log</i> will be
88 copied to <i>/foo/bar.log.2002-23</i>. Logging for the 24th week
89 of 2002 will be output to <code>/foo/bar.log</code> until it is
90 rolled over the next week.
91
92 <tr>
93 <td><code>'.'yyyy-MM-dd</code>
94
95 <td>Rollover at midnight each day.</td>
96
97 <td>At midnight, on March 8th, 2002, <code>/foo/bar.log</code> will
98 be copied to <code>/foo/bar.log.2002-03-08</code>. Logging for the
99 9th day of March will be output to <code>/foo/bar.log</code> until
100 it is rolled over the next day.
101
102 <tr>
103 <td><code>'.'yyyy-MM-dd-a</code>
104
105 <td>Rollover at midnight and midday of each day.</td>
106
107 <td>At noon, on March 9th, 2002, <code>/foo/bar.log</code> will be
108 copied to <code>/foo/bar.log.2002-03-09-AM</code>. Logging for the
109 afternoon of the 9th will be output to <code>/foo/bar.log</code>
110 until it is rolled over at midnight.
111
112 <tr>
113 <td><code>'.'yyyy-MM-dd-HH</code>
114
115 <td>Rollover at the top of every hour.</td>
116
117 <td>At approximately 11:00.000 o'clock on March 9th, 2002,
118 <code>/foo/bar.log</code> will be copied to
119 <code>/foo/bar.log.2002-03-09-10</code>. Logging for the 11th hour
120 of the 9th of March will be output to <code>/foo/bar.log</code>
121 until it is rolled over at the beginning of the next hour.
122
123
124 <tr>
125 <td><code>'.'yyyy-MM-dd-HH-mm</code>
126
127 <td>Rollover at the beginning of every minute.</td>
128
129 <td>At approximately 11:23,000, on March 9th, 2001,
130 <code>/foo/bar.log</code> will be copied to
131 <code>/foo/bar.log.2001-03-09-10-22</code>. Logging for the minute
132 of 11:23 (9th of March) will be output to
133 <code>/foo/bar.log</code> until it is rolled over the next minute.
134
135 </table>
136
137 <p>Do not use the colon ":" character in anywhere in the
138 <b>DatePattern</b> option. The text before the colon is interpeted
139 as the protocol specificaion of a URL which is probably not what
140 you want.
141*/
142
143 class LOG4CXX_EXPORT DailyRollingFileAppender : public log4cxx::rolling::RollingFileAppenderSkeleton {
144 DECLARE_LOG4CXX_OBJECT(DailyRollingFileAppender)
145 BEGIN_LOG4CXX_CAST_MAP()
146 LOG4CXX_CAST_ENTRY(DailyRollingFileAppender)
147 LOG4CXX_CAST_ENTRY_CHAIN(FileAppender)
148 END_LOG4CXX_CAST_MAP()
149
150 /**
151 The date pattern used to initiate rollover.
152 */
153 LogString datePattern;
154
155
156public:
157 /**
158 The default constructor simply calls its {@link
159 FileAppender#FileAppender parents constructor}. */
160 DailyRollingFileAppender();
161
162 /**
163 Instantiate a DailyRollingFileAppender and open the file designated by
164 <code>filename</code>. The opened filename will become the ouput
165 destination for this appender.
166
167 */
168 DailyRollingFileAppender(
169 const LayoutPtr& layout,
170 const LogString& filename,
171 const LogString& datePattern);
172
173
174 /**
175 The <b>DatePattern</b> takes a string in the same format as
176 expected by {@link log4cxx::helpers::SimpleDateFormat SimpleDateFormat}. This options determines the
177 rollover schedule.
178 */
179 void setDatePattern(const LogString& pattern);
180
181 /** Returns the value of the <b>DatePattern</b> option. */
182 LogString getDatePattern();
183
184 void setOption(const LogString& option,
185 const LogString& value);
186
187 /**
188 * Prepares DailyRollingFileAppender for use.
189 */
190 void activateOptions(log4cxx::helpers::Pool&);
191
192};
193
194LOG4CXX_PTR_DEF(DailyRollingFileAppender);
195
196}
197
198#if defined(_MSC_VER)
199#pragma warning ( pop )
200#endif
201
202
203#endif
Note: See TracBrowser for help on using the repository browser.