#! /bin/bash
####################################################
#Scripts for jbossWeb catalina.out cut every day
#eg: catalina.out.20121011
#Written by dxf
#at 2012-10-11
####################################################
BASE_LOG_PATH=/home/Gzh/shell/
JBOSS_LOG_PATH=/web/webserver/jboss/jboss-web-2.1.4.GA/logs/
cat ${JBOSS_LOG_PATH}catalina.out > ${JBOSS_LOG_PATH}catalina.out.`date -d today +%Y%m%d`
cat /dev/null > ${JBOSS_LOG_PATH}catalina.out
echo "cut ${JBOSS_LOG_PATH}catalina.out jbossWeb log successfully at `date -d today +"%F %r"`" >> ${BASE_LOG_PATH}cut_jboss.log
#---- 上面的内容放在文件中(位置随意)。让此文件变成可以执行文件!可执行的授权方法:
http://jackroomage.iteye.com/blog/1695551
#---------------解释说明
# 放shell脚本的位置
# BASE_LOG_PATH=/home/Gzh/shell/
# jboss的logs位置
# JBOSS_LOG_PATH=/web/webserver/jboss/jboss-web-2.1.4.GA/logs/
# 每天生成日志
# cat ${JBOSS_LOG_PATH}catalina.out > ${JBOSS_LOG_PATH}catalina.out.`date -d today +%Y%m%d`
# 每天清空上一天的日志
# cat /dev/null > ${JBOSS_LOG_PATH}catalina.out
# 记录每天成功生成日志的时间
# echo "cut ${JBOSS_LOG_PATH}catalina.out jbossWeb log successfully at `date -d today +"%F %r"`" >> ${BASE_LOG_PATH}cut_jboss.log
注意事项,在建shell脚本的时候,必须先修改(logging.properties)
logging.properties的位置在,(/web/webserver/jboss/jboss-web-2.1.4.GA/conf/logging.properties)
按照如下修改
修改logging.properties文件
handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4admin.org.apache.juli.FileHandler, 5host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
#1catalina.org.apache.juli.FileHandler.level = FINE
#1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
#1catalina.org.apache.juli.FileHandler.prefix = catalina.
#2localhost.org.apache.juli.FileHandler.level = FINE
#2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
#2localhost.org.apache.juli.FileHandler.prefix = localhost.
#3manager.org.apache.juli.FileHandler.level = FINE
#3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
#3manager.org.apache.juli.FileHandler.prefix = manager.
#4admin.org.apache.juli.FileHandler.level = FINE
#4admin.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
#4admin.org.apache.juli.FileHandler.prefix = admin.
#5host-manager.org.apache.juli.FileHandler.level = FINE
#5host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
#5host-manager.org.apache.juli.FileHandler.prefix = host-manager.
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################
#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler
#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler
#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin].level = INFO
#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin].handlers = 4admin.org.apache.juli.FileHandler
#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 5host-manager.org.apache.juli.FileHandler
# For example, set the com.xyz.foo logger to only log SEVERE
# messages:
#org.apache.catalina.startup.ContextConfig.level = FINE
#org.apache.catalina.startup.HostConfig.level = FINE
#org.apache.catalina.session.ManagerBase.level = FINE
#org.apache.catalina.core.AprLifecycleListener.level=FINE