This is an automated email from the ASF dual-hosted git repository. billblough pushed a commit to branch 29092007 in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit e36b4c0a3a7c7a661721027a60d21f6166921661 Author: Damitha N.M. Kumarage <[email protected]> AuthorDate: Fri Oct 26 06:14:03 2007 +0000 When axis2c server starts we can give the maximum log file size in mega bytes. --- .../http/server/simple_axis2_server/http_server_main.c | 10 +++++++++- util/include/axutil_log.h | 3 +++ util/src/log.c | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/transport/http/server/simple_axis2_server/http_server_main.c b/src/core/transport/http/server/simple_axis2_server/http_server_main.c index 53fce58..bbc0277 100644 --- a/src/core/transport/http/server/simple_axis2_server/http_server_main.c +++ b/src/core/transport/http/server/simple_axis2_server/http_server_main.c @@ -100,6 +100,7 @@ main( extern char *optarg; extern int optopt; int c; + int log_file_size; axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_DEBUG; const axis2_char_t *log_file = "axis2.log"; int port = 9090; @@ -109,7 +110,7 @@ main( set with AXIS2_REQUEST_URL_PREFIX macro at compile time */ axis2_request_url_prefix = AXIS2_REQUEST_URL_PREFIX; - while ((c = AXIS2_GETOPT(argc, argv, ":p:r:ht:l:f:")) != -1) + while ((c = AXIS2_GETOPT(argc, argv, ":p:r:ht:l:s:f:")) != -1) { switch (c) @@ -130,6 +131,9 @@ main( if (log_level > AXIS2_LOG_LEVEL_SERVICE) log_level = AXIS2_LOG_LEVEL_TRACE; break; + case 's': + log_file_size = AXIS2_ATOI(optarg); + break; case 'f': log_file = optarg; break; @@ -157,6 +161,7 @@ main( env = init_syetem_env(allocator, log_file); env->log->level = log_level; + env->log->size = 1024 * 1024 * log_file_size; axutil_error_init(); system_env = env; @@ -206,6 +211,7 @@ usage( fprintf(stdout, " [-r REPO_PATH]"); fprintf(stdout, " [-l LOG_LEVEL]"); fprintf(stdout, " [-f LOG_FILE]\n"); + fprintf(stdout, " [-s LOG_FILE_SIZE]\n"); fprintf(stdout, " Options :\n"); fprintf(stdout, "\t-p PORT \t port number to use, default port is 9090\n"); fprintf(stdout, "\t-r REPO_PATH \t repository path, default is ../\n"); @@ -219,6 +225,8 @@ usage( fprintf(stdout, "\t-f LOG_FILE\t log file, default is $AXIS2C_HOME/logs/axis2.log" "\n\t\t\t or axis2.log in current folder if AXIS2C_HOME not set\n"); + fprintf(stdout, + "\t-s LOG_FILE_SIZE\t Maximum log file size in mega bytes, default maximum size is 8MB.\n"); fprintf(stdout, " Help :\n\t-h \t display this help screen.\n\n"); } diff --git a/util/include/axutil_log.h b/util/include/axutil_log.h index 730ac65..16825d7 100644 --- a/util/include/axutil_log.h +++ b/util/include/axutil_log.h @@ -127,6 +127,9 @@ extern "C" /** Log level */ axutil_log_levels_t level; + + /** Maximum log file size */ + int size; /** Is logging enabled? */ axis2_bool_t enabled; diff --git a/util/src/log.c b/util/src/log.c index c526550..95d9ffb 100644 --- a/util/src/log.c +++ b/util/src/log.c @@ -169,6 +169,7 @@ axutil_log_create( tmp_filename); } log_impl->file_name = AXIS2_MALLOC(allocator, AXUTIL_LOG_FILE_NAME_SIZE); + log_impl->log.size = AXUTIL_LOG_FILE_SIZE; sprintf(log_impl->file_name, "%s", log_file_name); axutil_thread_mutex_lock(log_impl->mutex); @@ -307,7 +308,7 @@ axutil_log_impl_rotate( if(log_impl->file_name) size = axutil_file_handler_size(log_impl->file_name); - if(size >= AXUTIL_LOG_FILE_SIZE) + if(size >= log->size) { AXIS2_SNPRINTF(old_log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s%s", log_impl->file_name, ".old");
