OSDN Git Service

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