OSDN Git Service

corresponded to gcc4.3
[ultramonkey-l7/sslproxy.git] / logger / logger_impl.cpp
1 /*
2  * @file  logger_impl.cpp
3  * @brief logger module implementation class.
4  *
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6  * Copyright (C) 2008  NTT COMWARE Corporation.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  **********************************************************************/
24
25 #include <sstream>
26 #include <iomanip>
27 #include <limits.h>
28 #include <log4cxx/logmanager.h>
29 #include <log4cxx/helpers/loglog.h>
30 #include <log4cxx/rolling/rollingfileappender.h>
31 #include <log4cxx/rolling/fixedwindowrollingpolicy.h>
32 #include <log4cxx/rolling/sizebasedtriggeringpolicy.h>
33 #include <log4cxx/rolling/timebasedrollingpolicy.h>
34 #include <log4cxx/consoleappender.h>
35 #include <errno.h>
36 #include <stdexcept>
37
38 #include "logger_impl.h"
39 #include "parameter.h"
40 #include "lexical_cast.h"
41 #include "strict_time_based_rolling_policy.h"
42 #include "time_and_size_based_rolling_policy.h"
43
44 #define LOGGER_LAYOUT "%d{%Y/%m/%d %H:%M:%S} [%p] %c %m %t %F:%L%n"
45 #define LOGGER_DEFAULT_BUFFER_SIZE (8 * 1024)
46 #define LOGGER_SYSLOG_FACILITY "USER"
47 #define LOGGER_BACKUP_INDEX_LOWER_LIMIT (1)
48 #define LOGGER_BACKUP_INDEX_LIMIT (12)
49 #define LOGGER_FILESIZE_LOWER_LIMIT (65535)
50 #define LOGGER_FILE_PATTERN "%i"
51
52 #define LOGGER_LOG_FILENAME_KEY "sslproxy_log_filename"
53 #define LOGGER_ROTATION_KEY "sslproxy_rotation"
54 #define LOGGER_MAX_BACKUP_INDEX_KEY "sslproxy_max_backup_index"
55 #define LOGGER_MAX_FILE_SIZE_KEY "sslproxy_max_filesize"
56 #define LOGGER_ROTATION_TIMING_KEY "sslproxy_rotation_timing"
57 #define LOGGER_ROTATION_TIMING_VALUE_KEY "sslproxy_rotation_timing_value"
58
59 #define LOGGER_CONN_LOG_FILENAME_KEY "conn_log_filename"
60 #define LOGGER_CONN_ROTATION_KEY "conn_rotation"
61 #define LOGGER_CONN_MAX_BACKUP_INDEX_KEY "conn_max_backup_index"
62 #define LOGGER_CONN_MAX_FILE_SIZE_KEY "conn_max_filesize"
63 #define LOGGER_CONN_ROTATION_TIMING_KEY "conn_rotation_timing"
64 #define LOGGER_CONN_ROTATION_TIMING_VALUE_KEY "conn_rotation_timing_value"
65
66 //! for transration between log4cxx::LevelPtr and LOGER_LEVEL_TAG
67 char l7vs::LoggerImpl::categoryTable[][LOGGER_CATEGORY_NUM] = { 
68         "none",
69         "sslproxy_logger",
70         "sslproxy_parameter",
71         "sslproxy_common",
72         "sslproxy_server",
73         "sslproxy_session",
74         "sslproxy_connection",
75         "packet_edit",
76         "packet_edit_http",
77         "end"
78         };
79
80 //! for transration between string and LOGGER_CATEGORY_TAG
81 log4cxx::LevelPtr l7vs::LoggerImpl::levelTable[LOGGER_LEVEL_NUM];
82
83 /*!
84  * returns single instance.
85  *
86  * @param   void
87  * @return  instance
88  */
89 l7vs::LoggerImpl& l7vs::LoggerImpl::getInstance()
90 {
91         if (!instance) {
92                 instance = new LoggerImpl;
93         }
94         return *instance;
95 }
96
97 //! static Logger instance pointer initialized by 0.
98 l7vs::LoggerImpl* l7vs::LoggerImpl::instance = 0;
99
100 /*!
101  * initialize function.
102  * logger initialized to use syslogappender and fileappender(/dev/console)
103  *
104  * @param   void
105  * @retval  true succeed
106  * @retval  false failed
107  */
108 bool l7vs::LoggerImpl::init()
109 {
110         int ret = 0;
111         if (initialized) return false;
112
113         try {
114                 log4cxx::LoggerPtr root = log4cxx::Logger::getRootLogger();
115                 if (0 == root) {
116                         return false;
117                 }
118                 log4cxx::LayoutPtr layout =
119                         new log4cxx::PatternLayout(LOGGER_LAYOUT);
120                 log4cxx::net::SyslogAppenderPtr syslogAppender =
121                         new log4cxx::net::SyslogAppender(layout, log4cxx::net::SyslogAppender::getFacility(LOGGER_SYSLOG_FACILITY));
122                 root->addAppender(syslogAppender);
123                 log4cxx::WriterAppender* consoleAppender =
124                         new log4cxx::ConsoleAppender( layout, log4cxx::ConsoleAppender::getSystemErr() );
125                 root->addAppender(consoleAppender);
126
127                 for (LOG_CATEGORY_TAG cat = LOG_CAT_NONE; cat < LOG_CAT_END; ++cat) {
128                         log4cxx::Logger::getLogger(categoryTable[cat])->setLevel(categoryLevel[cat]);
129                 }
130         }
131         catch (const std::exception& e) {
132                 std::ostringstream oss;
133                 oss <<  "Logger Initialization Failed : " << e.what();
134                 errorConf(6, oss.str(), __FILE__, __LINE__);
135                 return false;
136         }
137         
138         ret = gethostname(hostname, HOST_NAME_LEN);
139         if (0 > ret) {
140                 if (LOG_LV_WARN >= this->getLogLevel(loggerCategory)) {
141                         this->putLogWarn(loggerCategory,1, "Fail to get Hostname", __FILE__, __LINE__);
142                 }
143         }       
144
145         if (LOG_LV_INFO >= this->getLogLevel(loggerCategory)) {
146                 this->putLogInfo(loggerCategory,1, "Logger Initialized.", __FILE__, __LINE__);
147         }
148
149         initialized = true;
150         return true;
151 }
152
153 /*!
154  * error handling function.
155  * if error occured, switch appenders to syslogappender and fileappender(/dev/console)
156  * message will output to syslog/fileappender appender
157  * 
158  * @param   log message id 
159  * @param   log message 
160  * @param   current file 
161  * @param   current line
162  * @return  void
163  */
164 void l7vs::LoggerImpl::errorConf(unsigned int message_id, const std::string& errorMessage, const char* file, int line)
165 {
166         try {
167                 log4cxx::LogManager::resetConfiguration();
168                 log4cxx::LoggerPtr root = log4cxx::Logger::getRootLogger();
169                 if (0 == root)
170                         return;
171                 log4cxx::LayoutPtr layout =
172                         new log4cxx::PatternLayout(LOGGER_LAYOUT);
173                 log4cxx::net::SyslogAppenderPtr syslogAppender =
174                         new log4cxx::net::SyslogAppender(layout, log4cxx::net::SyslogAppender::getFacility(LOGGER_SYSLOG_FACILITY));
175                 log4cxx::ConsoleAppender* consoleAppender = new log4cxx::ConsoleAppender(layout, log4cxx::ConsoleAppender::getSystemErr() );
176                 root->addAppender(consoleAppender);
177                 root->addAppender(syslogAppender);
178
179                 for (LOG_CATEGORY_TAG cat = LOG_CAT_NONE; cat < LOG_CAT_END; ++cat) {
180                         log4cxx::Logger::getLogger(categoryTable[cat])->setLevel(categoryLevel[cat]);
181                 }
182
183                 char buf[BUF_LEN];
184                 snprintf(buf, BUF_LEN, "%s%d%03d%04d %s %s", LOGGER_PROCESS_ID, LOG_LV_FATAL, loggerCategory, message_id, errorMessage.c_str(), hostname);
185                 log4cxx::Logger::getLogger(categoryTable[loggerCategory])->forcedLog(log4cxx::Level::getFatal(), buf, log4cxx::spi::LocationInfo(file, "", line));
186         }
187         catch (const std::exception& e) {
188                 std::ostringstream oss;
189                 oss <<  "Logger Error Output Failed : " << e.what() << "\n";
190                 fputs(oss.str().c_str(), stderr);
191         }
192 }
193
194 /*!
195  * load the logger parameter.
196  * get settings from parameter component, and configure log4cxx property
197  *
198  * @param   void
199  * @return  void
200  */
201 void l7vs::LoggerImpl::loadConf()
202 {
203         for (LOG_CATEGORY_TAG cat = LOG_CAT_NONE; cat < LOG_CAT_END; ++cat) {
204                 if (cat == LOG_CAT_SSLPROXY_CONNECTION) {
205                         // Connection category Logger setting.
206                         log_filename_key          = LOGGER_CONN_LOG_FILENAME_KEY;
207                         rotation_key              = LOGGER_CONN_ROTATION_KEY;
208                         max_backup_index_key      = LOGGER_CONN_MAX_BACKUP_INDEX_KEY;
209                         max_file_size_key         = LOGGER_CONN_MAX_FILE_SIZE_KEY;
210                         rotation_timing_key       = LOGGER_CONN_ROTATION_TIMING_KEY;
211                         rotation_timing_value_key = LOGGER_CONN_ROTATION_TIMING_VALUE_KEY;
212                         /*-------- DEBUG LOG for sslproxy --------*/
213                         if (LOG_LV_DEBUG >= this->getLogLevel(loggerCategory)) {
214                                 std::ostringstream oss;
215                                 oss << "function : void l7vs::LoggerImpl::loadConf() : "
216                                     << "Connection category Logger setting. "
217                                     << "cat = " << cat;
218                                 this->putLogDebug(loggerCategory, 1, oss.str(), __FILE__, __LINE__);
219                         }
220                         /*------ DEBUG LOG END for sslproxy ------*/
221                 } else {
222                         // Other category Logger setting.
223                         log_filename_key          = LOGGER_LOG_FILENAME_KEY;
224                         rotation_key              = LOGGER_ROTATION_KEY;
225                         max_backup_index_key      = LOGGER_MAX_BACKUP_INDEX_KEY;
226                         max_file_size_key         = LOGGER_MAX_FILE_SIZE_KEY;
227                         rotation_timing_key       = LOGGER_ROTATION_TIMING_KEY;
228                         rotation_timing_value_key = LOGGER_ROTATION_TIMING_VALUE_KEY;
229                         /*-------- DEBUG LOG for sslproxy --------*/
230                         if (LOG_LV_DEBUG >= this->getLogLevel(loggerCategory) &&
231                             cat != LOG_CAT_SSLPROXY_LOGGER) {
232                                 std::ostringstream oss;
233                                 oss << "function : void l7vs::LoggerImpl::loadConf() : "
234                                     << "Other category Logger setting. "
235                                     << "cat = " << cat;
236                                 this->putLogDebug(loggerCategory, 2, oss.str(), __FILE__, __LINE__);
237                         }
238                         /*------ DEBUG LOG END for sslproxy ------*/
239                 }
240                 loadCategoryLoggerConf(cat);
241         }
242         if (LOG_LV_INFO >= this->getLogLevel(loggerCategory)) {
243                 std::ostringstream oss;
244                 oss << "Logger Configuration Succeed.";
245                 this->putLogInfo(loggerCategory,2, oss.str(), __FILE__, __LINE__);
246         }
247
248         /*-------- DEBUG LOG for sslproxy --------*/
249         if (LOG_LV_DEBUG >= this->getLogLevel(loggerCategory)) {
250                 std::ostringstream oss;
251                 oss << "out_function : void l7vs::LoggerImpl::loadConf() : "
252                     << "loadCategoryLoggerConf() END.";
253                 this->putLogDebug(loggerCategory, 3, oss.str(), __FILE__, __LINE__);
254         }
255         /*------ DEBUG LOG END for sslproxy ------*/
256 }
257
258 /*!
259  * load the category logger parameter.
260  * get settings from parameter component of each category, and configure log4cxx property
261  *
262  * @param[in]   catnum  LOG_CATEGORY_TAG
263  * @return  void
264  */
265 void l7vs::LoggerImpl::loadCategoryLoggerConf(LOG_CATEGORY_TAG catnum)
266 {
267         std::string ret;
268
269         //get log filename
270         if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, log_filename_key)) {
271                 logFilename = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, log_filename_key);
272         }
273         else {
274                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
275                         this->putLogError(loggerCategory,1, "Not Exist Log Filename Setting.", __FILE__, __LINE__);
276                 }
277                 throw std::logic_error("Not Exist Log Filename Setting.");
278         }
279         
280         //get rotation
281         if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, rotation_key)) {
282                 std::string rotationStr = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, rotation_key);
283                 if ("size" == rotationStr) rotation = LOG_ROT_SIZE;
284                 else if ("date" == rotationStr) rotation = LOG_ROT_DATE;
285                 else if ("datesize" == rotationStr) rotation = LOG_ROT_DATESIZE;
286                 else {
287                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
288                                 this->putLogError(loggerCategory,2, "Invalid Log Rotation Setting.", __FILE__, __LINE__);
289                         }
290                         throw std::logic_error("Invalid Log Rotation Setting.");
291                 }
292         }
293         else {
294                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
295                         this->putLogError(loggerCategory,3, "Not Exist Log Rotation Setting.", __FILE__, __LINE__);
296                 }
297                 throw std::logic_error("Not Exist Log Rotation Setting.");
298         }
299
300         //get max backup index
301         if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, max_backup_index_key)) {
302                 std::string maxBackupIndexStr = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, max_backup_index_key);
303                 try {
304                         maxBackupIndex = lexical_cast<unsigned int>(maxBackupIndexStr);
305                 }
306                 catch (const l7vs::bad_lexical_cast& bc) {
307                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
308                                 this->putLogError(loggerCategory,4, "Invalid MaxBackupIndex Value.", __FILE__, __LINE__);
309                         }
310                         throw std::logic_error("Invalid MaxBackupIndex Value.");
311                 }
312                 if (LOGGER_BACKUP_INDEX_LOWER_LIMIT > maxBackupIndex) {
313                         std::ostringstream oss;
314                         oss << "Max Backup Index must at least " << LOGGER_BACKUP_INDEX_LOWER_LIMIT << ".";
315                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
316                                 this->putLogError(loggerCategory,5, oss.str(), __FILE__, __LINE__);
317                         }
318                         throw std::logic_error(oss.str());
319                 }               
320                 if (LOGGER_BACKUP_INDEX_LIMIT < maxBackupIndex) {
321                         std::ostringstream oss;
322                         oss << "Max Backup Index must at most " << LOGGER_BACKUP_INDEX_LIMIT << ".";
323                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
324                                 this->putLogError(loggerCategory,6, oss.str(), __FILE__, __LINE__);
325                         }
326                         throw std::logic_error(oss.str());
327                 }               
328         }
329         else {
330                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
331                         this->putLogError(loggerCategory,7, "Not Exist Log MaxBackupIndex Setting.", __FILE__, __LINE__);
332                 }
333                 throw std::logic_error("Not Exist Log MaxBackupIndex Setting.");
334         }
335
336         if (LOG_ROT_SIZE == rotation || LOG_ROT_DATESIZE == rotation) {
337                 // get max file size
338                 std::string maxFileSizeStr;
339                 if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, max_file_size_key)) {
340                         maxFileSizeStr = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, max_file_size_key);
341                 }
342                 else {
343                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
344                                 this->putLogError(loggerCategory,8, "Not Exist Log MaxFileSize Setting.", __FILE__, __LINE__);
345                         }
346                         throw std::logic_error("Not Exist Log MaxFileSize Setting.");
347                 }
348                 
349                 std::string size_val;
350                 std::string last_str = maxFileSizeStr.substr(maxFileSizeStr.length() - 1, 1);
351                 // when unit was specified
352                 if (("K" == last_str) || ("M" == last_str) || ("G" == last_str)) {
353                         size_val = maxFileSizeStr.substr(0, maxFileSizeStr.length() - 1);
354                 }
355                 else {
356                         size_val = maxFileSizeStr;
357                 }
358                         
359                 try {
360                         maxFileSize = lexical_cast<size_t>(size_val);
361                 }
362                 catch (const l7vs::bad_lexical_cast& bc) {
363                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
364                                 this->putLogError(loggerCategory,9, "Invalid FileSize Value.", __FILE__, __LINE__);
365                         }
366                         throw std::logic_error("Invalid FileSize Value.");
367                 }
368
369                 if ("K" == last_str) {
370                         if ((ULLONG_MAX / 1024) < maxFileSize) {
371                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
372                                         this->putLogError(loggerCategory,10, "Invalid FileSize Value.", __FILE__, __LINE__);
373                                 }
374                                 throw std::logic_error("Invalid FileSize Value.");
375                         }
376                         maxFileSize = maxFileSize * 1024;
377                 }
378                 else if ("M" == last_str) {
379                         if ((ULLONG_MAX / 1024 / 1024) < maxFileSize) {
380                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
381                                         this->putLogError(loggerCategory,11, "Invalid FileSize Value.", __FILE__, __LINE__);
382                                 }
383                                 throw std::logic_error("Invalid FileSize Value.");
384                         }
385                         maxFileSize = maxFileSize * 1024 * 1024;
386                 }
387                 else if ("G" == last_str) {
388                         if ((ULLONG_MAX / 1024 / 1024 / 1024) < maxFileSize) {
389                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
390                                         this->putLogError(loggerCategory,12, "Invalid FileSize Value.", __FILE__, __LINE__);
391                                 }
392                                 throw std::logic_error("Invalid FileSize Value.");
393                         }
394                         maxFileSize = maxFileSize * 1024 * 1024 * 1024;
395                 }
396                 if (LOGGER_FILESIZE_LOWER_LIMIT > maxFileSize) {
397                         int limit = LOGGER_FILESIZE_LOWER_LIMIT;
398                         std::ostringstream oss;
399                         oss << "FileSize must at least " << limit << " bytes.";
400                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
401                                 this->putLogError(loggerCategory,13, oss.str(), __FILE__, __LINE__);
402                         }
403                         throw std::logic_error(oss.str());
404                 }
405         }
406
407         if (LOG_ROT_DATE == rotation || LOG_ROT_DATESIZE == rotation) {
408                 // get rotation timing
409                 if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, rotation_timing_key)) {
410                         std::string rotationTimingStr = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, rotation_timing_key);
411                         if ("year" == rotationTimingStr) rotationTiming = LOG_TIM_YEAR;
412                         else if ("month" == rotationTimingStr) rotationTiming = LOG_TIM_MONTH;
413                         else if ("week" == rotationTimingStr) rotationTiming = LOG_TIM_WEEK;
414                         else if ("date" == rotationTimingStr) rotationTiming = LOG_TIM_DATE;
415                         else if ("hour" == rotationTimingStr) rotationTiming = LOG_TIM_HOUR;
416                         else {
417                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
418                                         this->putLogError(loggerCategory,14, "Invalid Log RotationTiming Setting.", __FILE__, __LINE__);
419                                 }
420                                 throw std::logic_error("Invalid Log RotationTiming Setting.");
421                         }
422                 }
423                 else {
424                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
425                                 this->putLogError(loggerCategory,15, "Not Exist Log RotaionTiming Setting.", __FILE__, __LINE__);
426                         }
427                         throw std::logic_error("Not Exist Log RotaionTiming Setting.");
428                 }
429
430                 if (LOG_TIM_YEAR == rotationTiming) {
431                         if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, rotation_timing_value_key)) {
432                                 ret = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, rotation_timing_value_key);
433
434                                 std::string::size_type fpos = 0;
435                                 std::string::size_type rpos = 0;
436                                 int month = 0;
437                                 int date = 0;
438                                 int hour = 0;
439                                 int minute = 0;
440                                 // find month
441                                 rpos = ret.find_first_of('/', fpos);
442                                 if (std::string::npos != rpos) {
443                                         std::string monthStr = ret.substr(fpos, rpos - fpos);
444                                         try {
445                                                 month = lexical_cast<int>(monthStr);
446                                         }
447                                         catch (const l7vs::bad_lexical_cast& bc) {
448                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
449                                                         this->putLogError(loggerCategory,16, "Parse Timing Year Error.", __FILE__, __LINE__);
450                                                 }
451                                                 throw std::logic_error("Parse Timing Year Error.");
452                                         }
453                                         if (1 > month || month > 12) {
454                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
455                                                         this->putLogError(loggerCategory,17, "Parse Timing Year Error.", __FILE__, __LINE__);
456                                                 }
457                                                 throw std::logic_error("Parse Timing Year Error.");
458                                         }
459                                         fpos = rpos + 1;
460                                         // find date
461                                         rpos = ret.find_first_of(' ', fpos);
462                                         if (std::string::npos != rpos) {
463                                                 std::string dateStr = ret.substr(fpos, rpos - fpos);
464                                                 try {
465                                                         date = lexical_cast<int>(dateStr);
466                                                 }
467                                                 catch (const l7vs::bad_lexical_cast& bc) {
468                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
469                                                                 this->putLogError(loggerCategory,18, "Parse Timing Year Error.", __FILE__, __LINE__);
470                                                         }
471                                                         throw std::logic_error("Parse Timing Year Error.");
472                                                 }
473                                                 if (1 > date || date > 31) {
474                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
475                                                                 this->putLogError(loggerCategory,19, "Parse Timing Year Error.", __FILE__, __LINE__);
476                                                         }
477                                                         throw std::logic_error("Parse Timing Year Error.");
478                                                 }
479                                                 int dates[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
480                                                 if (date > dates[month - 1]) {
481                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
482                                                                 this->putLogError(loggerCategory,20, "Parse Timing Year Error.", __FILE__, __LINE__);
483                                                         }
484                                                         throw std::logic_error("Parse Timing Year Error.");
485                                                 }
486                                                 fpos = rpos + 1;
487                                                 // find hour 
488                                                 rpos = ret.find_first_of(':', fpos);
489                                                 if (std::string::npos != rpos) {
490                                                         std::string hourStr = ret.substr(fpos, rpos - fpos);
491                                                         try {
492                                                                 hour = lexical_cast<int>(hourStr);
493                                                         }
494                                                         catch (const l7vs::bad_lexical_cast& bc) {
495                                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
496                                                                         this->putLogError(loggerCategory,21, "Parse Timing Year Error.", __FILE__, __LINE__);
497                                                                 }
498                                                                 throw std::logic_error("Parse Timing Year Error.");
499                                                         }
500                                                         if (0 > hour || hour > 23) {
501                                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
502                                                                         this->putLogError(loggerCategory,22, "Parse Timing Year Error.", __FILE__, __LINE__);
503                                                                 }
504                                                                 throw std::logic_error("Parse Timing Year Error.");
505                                                         }
506                                                         // minute
507                                                         std::string minuteStr = ret.substr(rpos + 1);
508                                                         try {
509                                                                 minute = lexical_cast<int>(minuteStr);
510                                                         }
511                                                         catch (const l7vs::bad_lexical_cast& bc) {
512                                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
513                                                                         this->putLogError(loggerCategory,23, "Parse Timing Year Error.", __FILE__, __LINE__);
514                                                                 }
515                                                                 throw std::logic_error("Parse Timing Year Error.");
516                                                         }
517                                                         if (0 > minute || minute > 59) {
518                                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
519                                                                         this->putLogError(loggerCategory,24, "Parse Timing Year Error.", __FILE__, __LINE__);
520                                                                 }
521                                                                 throw std::logic_error("Parse Timing Year Error.");
522                                                         }
523                                                 }
524                                                 else {
525                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
526                                                                 this->putLogError(loggerCategory,25, "Parse Timing Year Error.", __FILE__, __LINE__);
527                                                         }
528                                                         throw std::logic_error("Parse Timing Year Error.");
529                                                 }
530                                         }
531                                         else {
532                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {        
533                                                         this->putLogError(loggerCategory,26, "Parse Timing Year Error.", __FILE__, __LINE__);
534                                                 }
535                                                 throw std::logic_error("Parse Timing Year Error.");
536                                         }
537                                 }
538                                 else {
539                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
540                                                 this->putLogError(loggerCategory,27, "Parse Timing Year Error.", __FILE__, __LINE__);
541                                         }
542                                         throw std::logic_error("Parse Timing Year Error.");
543                                 }
544
545                                 // format to internal rotation timing value expresson
546                                 std::ostringstream oss;
547                                 oss << std::setfill('0') << std::setw(2) << month
548                                         << std::setfill('0') << std::setw(2) << date
549                                         << std::setfill('0') << std::setw(2) << hour
550                                         << std::setfill('0') << std::setw(2) << minute;
551                                 
552                                 rotationTimingValue = oss.str();
553
554                         }
555                         else {
556                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
557                                         this->putLogError(loggerCategory,28, "Not Exist Log RotaionTiming Year Setting.", __FILE__, __LINE__);
558                                 }
559                                 throw std::logic_error("Not Exist Log RotaionTiming Year Setting.");
560                         }
561                 }
562
563                 if (LOG_TIM_MONTH == rotationTiming) {
564                         if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, rotation_timing_value_key)) {
565                                 ret = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, rotation_timing_value_key);
566
567                                 std::string::size_type fpos = 0;
568                                 std::string::size_type rpos = 0;
569                                 int date = 0;
570                                 int hour = 0;
571                                 int minute = 0;
572                                 // find day
573                                 rpos = ret.find_first_of(' ', fpos);
574                                 if (std::string::npos != rpos) {
575                                         std::string dateStr = ret.substr(fpos, rpos - fpos);
576                                         try {
577                                                 date = lexical_cast<int>(dateStr);
578                                         }
579                                         catch (const l7vs::bad_lexical_cast& bc) {
580                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
581                                                         this->putLogError(loggerCategory,29, "Parse Timing Month Error.", __FILE__, __LINE__);
582                                                 }
583                                                 throw std::logic_error("Parse Timing Month Error.");
584                                         }
585                                         if (1 > date || date > 31) {
586                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
587                                                         this->putLogError(loggerCategory,30, "Parse Timing Month Error.", __FILE__, __LINE__);
588                                                 }
589                                                 throw std::logic_error("Parse Timing Month Error.");
590                                         }
591                                         fpos = rpos + 1;
592                                         // find hour
593                                         rpos = ret.find_first_of(':', fpos);
594                                         if (std::string::npos != rpos) {
595                                                 std::string hourStr = ret.substr(fpos, rpos - fpos);
596                                                 try {
597                                                         hour = lexical_cast<int>(hourStr);
598                                                 }
599                                                 catch (const l7vs::bad_lexical_cast& bc) {
600                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
601                                                                 this->putLogError(loggerCategory,31, "Parse Timing Month Error.", __FILE__, __LINE__);
602                                                         }
603                                                         throw std::logic_error("Parse Timing Month Error.");
604                                                 }
605                                                 if (0 > hour || hour > 23) {
606                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
607                                                                 this->putLogError(loggerCategory,32, "Parse Timing Month Error.", __FILE__, __LINE__);
608                                                         }
609                                                         throw std::logic_error("Parse Timing Month Error.");
610                                                 }
611                                                 // minute
612                                                 std::string minuteStr = ret.substr(rpos + 1);
613                                                 try {
614                                                         minute = lexical_cast<int>(minuteStr);
615                                                 }
616                                                 catch (const l7vs::bad_lexical_cast& bc) {
617                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
618                                                                 this->putLogError(loggerCategory,33, "Parse Timing Month Error.", __FILE__, __LINE__);
619                                                         }
620                                                         throw std::logic_error("Parse Timing Month Error.");
621                                                 }
622                                                 if (0 > minute || minute > 59) {
623                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
624                                                                 this->putLogError(loggerCategory,34, "Parse Timing Month Error.", __FILE__, __LINE__);
625                                                         }
626                                                         throw std::logic_error("Parse Timing Month Error.");
627                                                 }
628                                         }
629                                         else {
630                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
631                                                         this->putLogError(loggerCategory,35, "Parse Timing Month Error.", __FILE__, __LINE__);
632                                                 }
633                                                 throw std::logic_error("Parse Timing Month Error.");
634                                         }
635                                 }
636                                 else {
637                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
638                                                 this->putLogError(loggerCategory,36, "Parse Timing Month Error.", __FILE__, __LINE__);
639                                         }
640                                         throw std::logic_error("Parse Timing Month Error.");
641                                 }
642
643                                 // format to internal rotation timing value expresson
644                                 std::ostringstream oss;
645                                 oss << std::setfill('0') << std::setw(2) << date
646                                         << std::setfill('0') << std::setw(2) << hour
647                                         << std::setfill('0') << std::setw(2) << minute;
648                                 
649                                 rotationTimingValue = oss.str();
650
651                         }
652                         else {
653                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
654                                         this->putLogError(loggerCategory,37, "Not Exist Log RotaionTiming Month Setting.", __FILE__, __LINE__);
655                                 }
656                                 throw std::logic_error("Not Exist Log RotaionTiming Month Setting.");
657                         }
658                 }
659
660                 if (LOG_TIM_WEEK == rotationTiming) {
661                         if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, rotation_timing_value_key)) {
662                                 ret = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, rotation_timing_value_key);
663
664                                 std::string::size_type fpos = 0;
665                                 std::string::size_type rpos = 0;
666                                 int week = 0;
667                                 int hour = 0;
668                                 int minute = 0;
669                                 rpos = ret.find_first_of(' ', fpos);
670                                 //find week
671                                 if (std::string::npos != rpos) {
672                                         std::string weekStr = ret.substr(fpos, rpos - fpos);
673
674                                         if ("sun" == weekStr) week = 0;
675                                         else if ("mon" == weekStr) week = 1;
676                                         else if ("tue" == weekStr) week = 2;
677                                         else if ("wed" == weekStr) week = 3;
678                                         else if ("thu" == weekStr) week = 4;
679                                         else if ("fri" == weekStr) week = 5;
680                                         else if ("sat" == weekStr) week = 6;
681                                         else {
682                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
683                                                         this->putLogError(loggerCategory,38, "Parse Timing Week Error.", __FILE__, __LINE__);
684                                                 }
685                                                 throw std::logic_error("Parse Timing Week Error.");
686                                         }
687                                         fpos = rpos + 1;
688                                         // find hour
689                                         rpos = ret.find_first_of(':', fpos);
690                                         if (std::string::npos != rpos) {
691                                                 std::string hourStr = ret.substr(fpos, rpos - fpos);
692                                                 try {
693                                                         hour = lexical_cast<int>(hourStr);
694                                                 }
695                                                 catch (const l7vs::bad_lexical_cast& bc) {
696                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
697                                                                 this->putLogError(loggerCategory,39, "Parse Timing Week Error.", __FILE__, __LINE__);
698                                                         }
699                                                         throw std::logic_error("Parse Timing Week Error.");
700                                                 }
701                                                 if (0 > hour || hour > 23) {
702                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
703                                                                 this->putLogError(loggerCategory,40, "Parse Timing Week Error.", __FILE__, __LINE__);
704                                                         }
705                                                         throw std::logic_error("Parse Timing Week Error.");
706                                                 }
707                                                 // minute
708                                                 std::string minuteStr = ret.substr(rpos + 1);
709                                                 try {
710                                                         minute = lexical_cast<int>(minuteStr);
711                                                 }
712                                                 catch (const l7vs::bad_lexical_cast& bc) {
713                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
714                                                                 this->putLogError(loggerCategory,41, "Parse Timing Week Error.", __FILE__, __LINE__);
715                                                         }
716                                                         throw std::logic_error("Parse Timing Week Error.");
717                                                 }
718                                                 if (0 > minute || minute > 59) {
719                                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
720                                                                 this->putLogError(loggerCategory,42, "Parse Timing Week Error.", __FILE__, __LINE__);
721                                                         }
722                                                         throw std::logic_error("Parse Timing Week Error.");
723                                                 }
724                                         }
725                                         else {
726                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {        
727                                                         this->putLogError(loggerCategory,43, "Parse Timing Week Error.", __FILE__, __LINE__);
728                                                 }
729                                                 throw std::logic_error("Parse Timing Week Error.");
730                                         }
731                                 }
732                                 else {
733                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
734                                                 this->putLogError(loggerCategory,44, "Parse Timing Week Error.", __FILE__, __LINE__);
735                                         }
736                                         throw std::logic_error("Parse Timing Week Error.");
737                                 }
738
739                                 // format to internal rotation timing value expresson
740                                 std::ostringstream oss;
741                                 oss << std::setfill('0') << std::setw(1) << week
742                                         << std::setfill('0') << std::setw(2) << hour
743                                         << std::setfill('0') << std::setw(2) << minute;
744                                 
745                                 rotationTimingValue = oss.str();
746
747                         }
748                         else {
749                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
750                                         this->putLogError(loggerCategory,45, "Not Exist Log RotaionTiming Week Setting.", __FILE__, __LINE__);
751                                 }
752                                 throw std::logic_error("Not Exist Log RotaionTiming Week Setting.");
753                         }
754                 }
755
756                 if (LOG_TIM_DATE == rotationTiming) {
757                         if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, rotation_timing_value_key)) {
758                                 ret = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, rotation_timing_value_key);
759
760                                 std::string::size_type fpos = 0;
761                                 std::string::size_type rpos = 0;
762                                 int hour = 0;
763                                 int minute = 0;
764                                 //find time
765                                 rpos = ret.find_first_of(':', fpos);
766                                 if (std::string::npos != rpos) {
767                                         std::string hourStr = ret.substr(fpos, rpos - fpos);
768                                         try {
769                                                 hour = lexical_cast<int>(hourStr);
770                                         }
771                                         catch (const l7vs::bad_lexical_cast& bc) {
772                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
773                                                         this->putLogError(loggerCategory,46, "Parse Timing Date Error.", __FILE__, __LINE__);
774                                                 }
775                                                 throw std::logic_error("Parse Timing Date Error.");
776                                         }
777                                         if (0 > hour || hour > 23) {
778                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
779                                                         this->putLogError(loggerCategory,47, "Parse Timing Date Error.", __FILE__, __LINE__);
780                                                 }
781                                                 throw std::logic_error("Parse Timing Date Error.");
782                                         }
783                                         // minute
784                                         std::string minuteStr = ret.substr(rpos + 1);
785                                         try {
786                                                 minute = lexical_cast<int>(minuteStr);
787                                         }
788                                         catch (const l7vs::bad_lexical_cast& bc) {
789                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
790                                                         this->putLogError(loggerCategory,48, "Parse Timing Date Error.", __FILE__, __LINE__);
791                                                 }
792                                                 throw std::logic_error("Parse Timing Date Error.");
793                                         }
794                                         if (0 > minute || minute > 59) {
795                                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
796                                                         this->putLogError(loggerCategory,49, "Parse Timing Date Error.", __FILE__, __LINE__);
797                                                 }
798                                                 throw std::logic_error("Parse Timing Date Error.");
799                                         }
800                                 }
801                                 else {
802                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
803                                                 this->putLogError(loggerCategory,50, "Parse Timing Date Error.", __FILE__, __LINE__);
804                                         }
805                                         throw std::logic_error("Parse Timing Date Error.");
806                                 }
807
808                                 // format to internal rotation timing value expresson
809                                 std::ostringstream oss;
810                                 oss << std::setfill('0') << std::setw(2) << hour
811                                         << std::setfill('0') << std::setw(2) << minute;
812                                 
813                                 rotationTimingValue = oss.str();
814
815                         }
816                         else {
817                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
818                                         this->putLogError(loggerCategory,51, "Not Exist Log RotaionTiming Date Setting.", __FILE__, __LINE__);
819                                 }
820                                 throw std::logic_error("Not Exist Log RotaionTiming Date Setting.");
821                         }
822                 }
823
824                 if (LOG_TIM_HOUR == rotationTiming) {
825                         if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, rotation_timing_value_key)) {
826                                 ret = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, rotation_timing_value_key);
827
828                                 // minute
829                                 int minute = 0;
830                                 try {
831                                         minute = lexical_cast<int>(ret);
832                                 }
833                                 catch (const l7vs::bad_lexical_cast& bc) {
834                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
835                                                 this->putLogError(loggerCategory,52, "Parse Timing Hour Error.", __FILE__, __LINE__);
836                                         }
837                                         throw std::logic_error("Parse Timing Hour Error.");
838                                 }
839                                 if (0 > minute || minute > 59) {
840                                         if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
841                                                 this->putLogError(loggerCategory,53, "Parse Timing Hour Error.", __FILE__, __LINE__);
842                                         }
843                                         throw std::logic_error("Parse Timing Hour Error.");
844                                 }
845
846                                 // format to internal rotation timing value expresson
847                                 std::ostringstream oss;
848                                 oss << std::setfill('0') << std::setw(2) << minute;
849                                 
850                                 rotationTimingValue = oss.str();
851
852                         }
853                         else {
854                                 if (LOG_LV_ERROR >= this->getLogLevel(loggerCategory)) {
855                                         this->putLogError(loggerCategory,54, "Not Exist Log RotaionTiming Hour Setting.", __FILE__, __LINE__);
856                                 }
857                                 throw std::logic_error("Not Exist Log RotaionTiming Hour Setting.");
858                         }
859                 }
860         }
861
862         try {
863                 /*-------- DEBUG LOG for sslproxy --------*/
864                 if (LOG_LV_DEBUG >= this->getLogLevel(loggerCategory) &&
865                     catnum != LOG_CAT_SSLPROXY_LOGGER) {
866                         std::ostringstream oss;
867                         oss << "function : void l7vs::LoggerImpl::loadCategoryLoggerConf("
868                             << "LOG_CATEGORY_TAG catnum) : "
869                             << "Set category Logger appender. "
870                             << "catnum = " << catnum;
871                         this->putLogDebug(loggerCategory, 4, oss.str(), __FILE__, __LINE__);
872                 }
873                 /*------ DEBUG LOG END for sslproxy ------*/
874
875                 // reset current configuration
876                 // when category is LOG_CAT_NONE (first category)
877                 log4cxx::helpers::Pool pool;
878                 if (catnum == LOG_CAT_NONE) {
879                         /*-------- DEBUG LOG for sslproxy --------*/
880                         if (LOG_LV_DEBUG >= this->getLogLevel(loggerCategory) &&
881                             catnum != LOG_CAT_SSLPROXY_LOGGER) {
882                                 std::ostringstream oss;
883                                 oss << "function : l7vs::LoggerImpl::loadCategoryLoggerConf() : "
884                                     << "Reset all Logger configuration. "
885                                     << "catnum = " << catnum;
886                                 this->putLogDebug(loggerCategory, 5, oss.str(), __FILE__, __LINE__);
887                         }
888                         /*------ DEBUG LOG END for sslproxy ------*/
889                         log4cxx::LogManager::resetConfiguration();
890                 }
891                 log4cxx::LoggerPtr catlogger = log4cxx::Logger::getLogger(categoryTable[catnum]);
892                 if (0 == catlogger) {
893                         throw std::logic_error("getLogger Failed.");
894                 }
895                 log4cxx::LayoutPtr layout =
896                         new log4cxx::PatternLayout(LOGGER_LAYOUT);
897
898                 switch (rotation) {
899                 case LOG_ROT_SIZE:
900                         {
901                                 // create FixedWindowRollingPolicy
902                                 log4cxx::rolling::FixedWindowRollingPolicyPtr fixedRollingPolicy =
903                                         new log4cxx::rolling::FixedWindowRollingPolicy();
904         
905                                 // setting minIndex
906                                 fixedRollingPolicy->setMinIndex(1);
907         
908                                 // setting maxIndex
909                                 fixedRollingPolicy->setMaxIndex(maxBackupIndex);
910
911                                 // setting FileNamePattern
912                                 std::ostringstream sizeFile;
913                                 sizeFile << logFilename << "." << LOGGER_FILE_PATTERN;
914                                 fixedRollingPolicy->setFileNamePattern(sizeFile.str());
915         
916                                 // create SizeBasedTriggeringPolicy
917                                 log4cxx::rolling::SizeBasedTriggeringPolicyPtr sizeTriggeringPolicy =
918                                         new log4cxx::rolling::SizeBasedTriggeringPolicy();
919
920                                 // setting maxFileSize
921                                 sizeTriggeringPolicy->setMaxFileSize(maxFileSize);
922         
923                                 // create RollingFileAppender
924                                 log4cxx::rolling::RollingFileAppenderPtr sizeAppender =
925                                         new log4cxx::rolling::RollingFileAppender();
926         
927                                 // set layout
928                                 sizeAppender->setLayout(layout);
929         
930                                 // set RollingPolicy
931                                 sizeAppender->setRollingPolicy(fixedRollingPolicy);
932         
933                                 // set TriggeringPolicy
934                                 sizeAppender->setTriggeringPolicy(sizeTriggeringPolicy);
935
936                                 // set Log Filename
937                                 sizeAppender->setFile(logFilename, true, false, LOGGER_DEFAULT_BUFFER_SIZE, pool);
938         
939                                 // activate appender options
940                                 sizeAppender->activateOptions(pool);
941         
942                                 // add size_base_appender to CategoryLogger
943                                 catlogger->addAppender(sizeAppender);
944
945                                 break;
946                         }
947                 case LOG_ROT_DATE:
948                         {
949                                 // create StrictTimeBasedRollingPolicy
950                                 log4cxx::rolling::StrictTimeBasedRollingPolicyPtr strictRollingPolicy =
951                                         new log4cxx::rolling::StrictTimeBasedRollingPolicy();
952         
953                                 // setting minIndex
954                                 strictRollingPolicy->setMinIndex(1);
955         
956                                 // setting maxIndex
957                                 strictRollingPolicy->setMaxIndex(maxBackupIndex);
958
959                                 // setting FileNamePattern
960                                 std::ostringstream dateFile;
961                                 dateFile << logFilename << "." << LOGGER_FILE_PATTERN;
962                                 strictRollingPolicy->setFileNamePattern(dateFile.str());
963
964                                 // setting Rotation Timing
965                                 strictRollingPolicy->setRotationTiming(rotationTiming);
966         
967                                 // setting Rotation Timing Value
968                                 strictRollingPolicy->setRotationTimingValue(rotationTimingValue);
969         
970                                 //create RollingFileAppender
971                                 log4cxx::rolling::RollingFileAppenderPtr dateAppender =
972                                         new log4cxx::rolling::RollingFileAppender();
973                         
974                                 // set layout
975                                 dateAppender->setLayout(layout);
976
977                                 // set RollingPolicy (TriggeringPolicy also included RollingPolicy)
978                                 dateAppender->setRollingPolicy(strictRollingPolicy);
979         
980                                 // set Log Filename
981                                 dateAppender->setFile(logFilename, true, false, LOGGER_DEFAULT_BUFFER_SIZE, pool);
982         
983                                 // activate appender options
984                                 dateAppender->activateOptions(pool);
985         
986                                 // add date_based_appender to CategoryLogger
987                                 catlogger->addAppender(dateAppender);
988
989                                 break;
990                         }
991                 default:        //LOG_ROT_DATESIZE:
992                         {
993                                 // create TimeAndSizeBasedRollingPolicy
994                                 log4cxx::rolling::TimeAndSizeBasedRollingPolicyPtr timeSizeRollingPolicy =
995                                         new log4cxx::rolling::TimeAndSizeBasedRollingPolicy();
996         
997                                 // setting minIndex
998                                 timeSizeRollingPolicy->setMinIndex(1);
999         
1000                                 // setting maxIndex
1001                                 timeSizeRollingPolicy->setMaxIndex(maxBackupIndex);
1002
1003                                 // setting FileNamePattern
1004                                 std::ostringstream dateSizeFile;
1005                                 dateSizeFile << logFilename << "." << LOGGER_FILE_PATTERN;
1006                                 timeSizeRollingPolicy->setFileNamePattern(dateSizeFile.str());
1007         
1008                                 // setting Rotation Timing
1009                                 timeSizeRollingPolicy->setRotationTiming(rotationTiming);
1010         
1011                                 // setting Rotation Timing Value
1012                                 timeSizeRollingPolicy->setRotationTimingValue(rotationTimingValue);
1013         
1014                                 // setting MaxFileSize
1015                                 timeSizeRollingPolicy->setMaxFileSize(maxFileSize);
1016         
1017                                 // create Rolling FileAppender
1018                                 log4cxx::rolling::RollingFileAppenderPtr dateSizeAppender =
1019                                         new log4cxx::rolling::RollingFileAppender();
1020         
1021                                 // set layout
1022                                 dateSizeAppender->setLayout(layout);
1023         
1024                                 // set RollingPolicy (TriggeringPolicy also included RollingPolicy)
1025                                 dateSizeAppender->setRollingPolicy(timeSizeRollingPolicy);
1026         
1027                                 // set Log Filename
1028                                 dateSizeAppender->setFile(logFilename, true, false, LOGGER_DEFAULT_BUFFER_SIZE, pool);
1029         
1030                                 // activate appender options
1031                                 dateSizeAppender->activateOptions(pool);
1032         
1033                                 // add time_and_size_based_appender to CategoryLogger
1034                                 catlogger->addAppender(dateSizeAppender);
1035                         }
1036                 }
1037
1038                 //set default log level
1039                 for (LOG_CATEGORY_TAG cat = LOG_CAT_NONE; cat < LOG_CAT_END; ++cat) {
1040                         log4cxx::Logger::getLogger(categoryTable[cat])->setLevel(categoryLevel[cat]);
1041                 }
1042
1043                 //get category level
1044                 for (LOG_CATEGORY_TAG cat = LOG_CAT_NONE; cat < LOG_CAT_END; ++cat) {
1045                         if (cat == LOG_CAT_NONE) continue;
1046                         if (l7vs::Parameter::getInstance().isStringExist(PARAM_COMP_LOGGER, categoryTable[cat])) {
1047                                 std::string levelStr = l7vs::Parameter::getInstance().getStringValue(PARAM_COMP_LOGGER, categoryTable[cat]);
1048                                 if ("debug" == levelStr) {
1049                                         categoryLevel[cat] = log4cxx::Level::getDebug();
1050                                         log4cxx::Logger::getLogger(categoryTable[cat])->setLevel(categoryLevel[cat]);
1051                                 }
1052                                 else if ("info" == levelStr) {
1053                                         categoryLevel[cat] = log4cxx::Level::getInfo();
1054                                         log4cxx::Logger::getLogger(categoryTable[cat])->setLevel(categoryLevel[cat]);
1055                                 }
1056                                 else if ("warn" == levelStr) {
1057                                         categoryLevel[cat] = log4cxx::Level::getWarn();
1058                                         log4cxx::Logger::getLogger(categoryTable[cat])->setLevel(categoryLevel[cat]);
1059                                 }
1060                                 else if ("error" == levelStr) {
1061                                         categoryLevel[cat] = log4cxx::Level::getError();
1062                                         log4cxx::Logger::getLogger(categoryTable[cat])->setLevel(categoryLevel[cat]);
1063                                 }
1064                                 else if ("fatal" == levelStr) {
1065                                         categoryLevel[cat] = log4cxx::Level::getFatal();
1066                                         log4cxx::Logger::getLogger(categoryTable[cat])->setLevel(categoryLevel[cat]);
1067                                 }
1068                                 else {
1069                                         std::ostringstream oss;
1070                                         oss << "Invalid Log Category Setting : " << categoryTable[cat];
1071                                         if (LOG_LV_WARN >= this->getLogLevel(loggerCategory)) {
1072                                                 this->putLogWarn(loggerCategory,2, oss.str(), __FILE__, __LINE__);
1073                                         }
1074                                         categoryLevel[cat] = log4cxx::Level::getInfo();
1075                                         log4cxx::Logger::getLogger(categoryTable[cat])->setLevel(categoryLevel[cat]);
1076                                 }
1077                         }
1078                         else {
1079                                 std::ostringstream oss;
1080                                 oss << "Not Exist Log Category Setting : " << categoryTable[cat];
1081                                 if (LOG_LV_WARN >= this->getLogLevel(loggerCategory)) {
1082                                         this->putLogWarn(loggerCategory,3, oss.str(), __FILE__, __LINE__);
1083                                 }
1084                                 categoryLevel[cat] = log4cxx::Level::getInfo();
1085                                 log4cxx::Logger::getLogger(categoryTable[cat])->setLevel(categoryLevel[cat]);
1086                         }
1087                 }
1088         }
1089         catch (const std::exception& e) {
1090                 std::ostringstream oss;
1091                 oss <<  "Logger Reload Config Failed : " << e.what();
1092                 errorConf(7, oss.str(), __FILE__, __LINE__);
1093                 throw std::logic_error(oss.str());
1094         }
1095
1096         initLogLevelTable();
1097 }
1098
1099 /*!
1100  * initialize LogLevel table.
1101  * initialize the LogLevel table.
1102  *
1103  * @param   void
1104  * @return  void
1105  */
1106 void l7vs::LoggerImpl::initLogLevelTable(void)
1107 {
1108         int nCounter = 0;
1109
1110         for (;nCounter < LOGGER_CATEGORY_NUM; nCounter++) {
1111                 loglevel[nCounter] = LOG_LV_NONE;
1112         }
1113
1114         return;
1115 }