Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Apache split log

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

When we visit the website, there will be records left. This is the log file, and the log information includes (source ip, access time, etc.)

1. The configuration of the log file already exists in the configuration file of the virtual host. We just need to open it.

Vi / usr/local/apache2/conf/extra/httpd-vhosts.conf

There is a common in the log that indicates the format of the log. Change it to combined.

two。 You can modify the name of the log

Change to test.com-error_log

Test.com-access_log

The default log path is / usr/local/apache2/logs/

3. Restart and reload after setting up

Apachectl-t

Apachectl graceful

4. Refresh the web page

Enter the log directory to see if a log file has been generated

Cd / usr/local/apache2/logs/

Ls View Files

Cat test.com-access_log can view access log messages

Log format: LogFormat "% h% l% u% t% T\"% r\ "% > s% b\"% {Referer} I\ "\"% {User-Agent} I\ ""

% h remote host

L remote login

% u remote user name

% t time, in normal log time format

% T took time to process the request in seconds

The first line of the r request, action

The last two of the source ip do not exist, all are represented by-- (LRV: represents the user)

5. View the capacity of log files

Wc-l test.com-access_log

What should be done to sort the formats by time?

Add something to the virtual host log configuration file

CustomLog "| / usr/local/apache2/bin/rotatelogs-l / usr/local/apache2/logs/test.com-access_%Y%m%d_log 86400" combined

Refresh the page and generate a log with a date

Modify the date, and then refresh the page to see if a log has been generated.

Date-s "2016-11-21 15:55:20"

Refresh the web page and generate a new log file

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report