2 * @file logger_implement_access.cpp
3 * @brief logger module implementation class For access log.
5 * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6 * Copyright (C) 2009 NTT COMWARE Corporation.
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.
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.
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
23 **********************************************************************/
30 #include <log4cxx/logmanager.h>
31 #include <log4cxx/helpers/loglog.h>
32 #include <log4cxx/rolling/rollingfileappender.h>
33 #include <log4cxx/rolling/fixedwindowrollingpolicy.h>
34 #include <log4cxx/rolling/sizebasedtriggeringpolicy.h>
35 #include <log4cxx/rolling/timebasedrollingpolicy.h>
36 #include <log4cxx/consoleappender.h>
39 #include <boost/lexical_cast.hpp>
41 #include "logger_implement_access.h"
44 bool l7vs::logger_implement_access::rtn_init_flag;
46 bool l7vs::logger_implement_access::rtn_checkRotateParameterComp_flag;
48 bool l7vs::logger_implement_access::rtn_setAcLoggerConf_flag;
51 l7vs::logger_implement_access::logger_implement_access(const std::string &access_log_file_name)
52 :rotate_default_flag( false ),
55 access_log_file_name_ = access_log_file_name;
61 bool l7vs::logger_implement_access::init(const bool rotate_default_flag,const appender_property& access_log_default_property,accesslog_rotate_map_type& rotatedata)
63 bool rtn = l7vs::logger_implement_access::rtn_init_flag;
70 bool l7vs::logger_implement_access::setAcLoggerConf(const appender_property& access_log_default_property,accesslog_rotate_map_type& rotatedata)
72 bool rtn = l7vs::logger_implement_access::rtn_setAcLoggerConf_flag;
79 void l7vs::logger_implement_access::addRef()
85 void l7vs::logger_implement_access::releaseRef()
91 bool l7vs::logger_implement_access::operator<=(const int access_num )
93 return( access_cnt <= access_num );
96 std::string l7vs::logger_implement_access::getAcLogFileName()
98 return( access_log_file_name_ );
102 bool l7vs::logger_implement_access::checkRotateParameterComp(accesslog_rotate_map_type &rotatedata)
104 bool rtn = l7vs::logger_implement_access::rtn_checkRotateParameterComp_flag;
109 bool l7vs::logger_implement_access::is_rotate_default_flag()
111 bool rtn = rotate_default_flag;
116 //
\83\8d\83O
\83t
\83H
\81[
\83}
\83b
\83g 2008/12/07 20:08:31 [INFO] [[AccessLog] (CL)192.168.2.1 --> 192.168.2.2 --UM-- 192.168.1.101:37259 --> (RS-DST)192.168.1.106:80 ]
118 * output access info log.
120 * @param virtualservice endpoint info
121 * @param client endpoint info
122 * @param realserver connect origin info
123 * @param realserver connect destination info
127 void l7vs::logger_implement_access::putLog(
128 const std::string& vsinfo,
129 const std::string& cl_con_org,
130 const std::string& rs_con_org,
131 const std::string& rs_con_dest,
132 const std::string& msg){
134 std::stringstream buf;
135 buf << boost::format( "[ [AccessLog] (CL)%s --> %s --UM-- %s --> (RS-DST)%s %s]" )
136 % LOGGER_ACCESS_PROCESS_ID
144 log4cxx::Logger::getLogger( access_log_file_name_ )->forcedLog( log4cxx::Level::getInfo(),
146 log4cxx::spi::LocationInfo("", "", 0));
148 catch (const std::exception& ex) {
149 std::ostringstream oss;
150 oss << "Logging Error (Access Log) : " << ex.what();
151 std::cout << oss.str() << "\n";
\r