• cronolog切割apache和tomcat日志


    cronolog切割apache和tomcat日志

    http://cronolog.org
    tar zxvf cronolog-1.6.2.tar.gz
    cd cronolog-1.6.2
    ./configure --prefix=/data/cronolog
    make
    make install

    查看 cronolog 安装后所在目录
    which cronolog
    /data/cronolog/sbin/cronlog


    一.分割tomcat日志
    要想分割 tomcat 的 catalina.out,需作如下工作:
    1.注释掉#
    #touch "$CATALINA_OUT"
    较老版本注释:touch “$CATALINA_BASE”/logs/catalina.out

    2.修改 tomcat bin 目录下的 catalina.sh 文件中的两处:
    org.apache.catalina.startup.Bootstrap "$@" start
    >> "$CATALINA_OUT" 2>&1 &

    org.apache.catalina.startup.Bootstrap "$@" start    
    2>&1 |/data/cronolog/sbin/cronolog "$CATALINA_BASE/logs/catalina-%Y-%m-%d.out" &
    3.日志分割后,启动 tomcat 务必请使用./startup.sh &启动。



    二.分割apache日志
    说明:apache安装目录为/data/apache
    1)修改 httpd-vhosts.conf 文件中对应的区域如下, 对日志进行分割,以及分割日志目录在每个 VirtualHost 中都加两句配置。
    TransferLog "|/data/cronolog/sbin/cronolog /data/apache/logs/www.xxx.log%Y%m%d"
    ErrorLog "|/data/cronolog/sbin/cronolog /data/apache/logs/www.xxx.log%Y%m%d"

    /data/cronolog/sbin/cronolog这个由which cronolog获得
    /data/apache/logs  该目录为apache的logs的安装目录
    ###########################
    还有一种:
    注释掉如下两行
    ErrorLog logs/error_log
    CustomLog logs/access_log common
    然后添加如下两行
    ErrorLog "|/data/cronolog/sbin/cronolog /data/apache/logs/www.xxx.log%Y%m%d"
    CustomLog "|/data/cronolog/sbin/cronolog /data/apache/logs/www.xxx.log%Y%m%d" common

    ##########采用电信云安装#############
    采用电信云防护系统时,配置如下:
    1)vim httpd.conf 文件添加代码:
    LogFormat "%h %{X-Forwarded-For}i %l %u %t "%r" %>s %b "%{Referer}i" "%{User- Agent}i"" combined

    http-vhost.conf 文件<VirtualHost>内添加如下代码
    CustomLog "|/data/cronolog/sbin/cronolog /data/apache/logs/access_log.%Y%m%d" combined
    ErrorLog "|/data/cronolog/sbin/cronolog /data/apache/logs/error_log.%Y%m%d"


    2)配置虚拟目录
    Alias /wwwlogs "/data/apache/logs/"

    <Directory "/data/apache/logs/">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from    all
    </Directory>

    验证方法:http://www.xxx.cn/wwwlogs 看是否能访问。

    注:如果客户有安全要求,则把虚拟目录中的 Allow from    all 改为 Allow from 允许访问的ip。

  • 相关阅读:
    Webpack 打包 14. html压缩
    webpack优化环境配置 18.HMR
    Webpack 打包 10. 压缩CSS
    Wenpack 打包 15. 生产环境配置(提取JS中的CSS、压缩CSS、压缩html、eslint语法检查...)
    Webpack 打包 13. 压缩JS
    webpack优化环境配置 17.优化配置介绍
    Webpack 打包 11. eslint 语法检查
    AtCoder Beginner Contest 258
    AtCoder Beginner Contest 259
    AtCoder Beginner Contest 261
  • 原文地址:https://www.cnblogs.com/fengzhongzhuzu/p/9853706.html
Copyright © 2020-2023  润新知