直接通过配置文件来指定log文件的输出地址

本文介绍了如何在Tomcat、Nginx、MySQL和Hadoop中修改配置文件,以指定日志文件的输出地址。在Tomcat的logging.properties和catalina.sh中进行设置,Nginx的nginx.conf,MySQL的my.cnf,以及Hadoop的Hadoop-env.sh中分别进行相应修改。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1Tomcat

1.1 修改tomcat/conf下的logging.properties 

############################################################

# Handler specific properties.

# Describes specific configuration info for Handlers.

############################################################

 

1catalina.org.apache.juli.FileHandler.level = FINE

1catalina.org.apache.juli.FileHandler.directory =你自己指定的地址

1catalina.org.apache.juli.FileHandler.prefix = catalina.

 

2localhost.org.apache.juli.FileHandler.level = FINE

2localhost.org.apache.juli.FileHandler.directory =你自己指定的地址

2localhost.org.apache.juli.FileHandler.prefix = localhost.

 

3manager.org.apache.juli.FileHandler.level = FINE

3manager.org.apache.juli.FileHandler.directory =你自己指定的地址

3manager.org.apache.juli.FileHandler.prefix = manager.

 

4host-manager.org.apache.juli.FileHandler.level = FINE

4host-manager.org.apache.juli.FileHandler.directory =你自己指定的地址

4host-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.

############################################################

 

1.2 修改tomcat/bin/catalina.sh 

if [ -z "$CATALINA_OUT" ] ; then

   CATALINA_OUT= 你自己指定的地址/catalina.out

 fi

 

1.3 修改tomcat/config/server.xml

<!-- Access log processes all example.  
           Documentation at: /docs/config/valve.html  
           Note: The pattern used is equivalent to using pattern="common" -->  
      <Valve className="org.apache.catalina.valves.AccessLogValve" directory="你自己指定的路径" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/>  

2nignx

{nignx_home}/conf/nginx.conf

#user  nobody;

worker_processes  1;

 

error_log   /home/iptv/fresh/log/nginx/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

 

#pid        logsinx.pid;

 

events {

    worker_connections  1024;

}

 

http {

    include       mime.types;

    default_type  application/octet-stream;

 

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

    #                  '$status $body_bytes_sent "$http_referer" '

    #                  '"$http_user_agent" "$http_x_forwarded_for"';

 

   access_log  /home/iptv/fresh/log/nginx/access.log ;

 

    sendfile        on;

    #tcp_nopush     on;

 

    #keepalive_timeout  0;

    keepalive_timeout  65;

 

    #gzip  on;

 

    server {

        listen       8908;

        server_name  localhost;

 

        #charset koi8-r;

 

        access_log  /home/iptv/fresh/log/nginx/host.access.log;

 

        location / {

            root   /FTP;

            index  index.php index.html index.htm;

        }

 

        #error_page  404              /404.html;

 

        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

 

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}

 

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        #location ~ \.php$ {

        #    root           html;

        #    fastcgi_pass   127.0.0.1:9000;

        #    fastcgi_index  index.php;

        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

        #    include        fastcgi_params;

        #}

 

        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        #location ~ /\.ht {

        #    deny  all;

        #}

    }

 

 

    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;

 

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

 

 

    # HTTPS server

    #

    #server {

    #    listen       443 ssl;

    #    server_name  localhost;

 

    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;

 

    #    ssl_session_cache    shared:SSL:1m;

    #    ssl_session_timeout  5m;

 

    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;

 

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

}

tcp {

access_log/home/iptv/fresh/log/nginx/tcp_access.log           upstream activeMQStompProxy {

 

        # simple round-robin

                # server IP:port;

        

server 192.168.21.128:61613;

 

server 192.168.21.128:61615;

check interval=3000 rise=2 fall=5 timeout=1000;

 

        #check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello;

 

        #check interval=3000 rise=2 fall=5 timeout=1000 type=http;

        #check_http_send "GET / HTTP/1.0\r\n\r\n";

        #check_http_expect_alive http_2xx http_3xx;

    }

 

    server {

        listen 9999;                 

        proxy_pass activeMQStompProxy;

    }

}

3MySQL

/etc/my.cnf

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

 

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

 

4hadoop

{hadoop_home}/etc/hadoop/conf/Hadoop-env.sh 修改下面这句话

export HADOOP_LOG_DIR=/mnt/disk1/hadoop-hdfs    # 指向自定义的路径  


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值