Log Files
In order to effectively manage a web server, it is necessary to get feedback about the activity and performance of the server as well as any problems that may be occurring. The Apache HTTP Server provides very comprehensive and flexible logging capabilities. This document describes how to configure its logging capabilities, and how to understand what the logs contain.
Overview
| Related Modules | Related Directives |
|---|---|
The Apache HTTP Server provides a variety of different mechanisms for logging everything that happens on your server, from the initial request, through the URL mapping process, to the final resolution of the connection, including any errors that may have occurred in the process. In addition to this, third-party modules may provide logging capabilities, or inject entries into the existing log files, and applications such as CGI programs, or PHP scripts, or other handlers, may send messages to the server error log.
In this document we discuss the logging modules that are a standard part of the http server.
Security Warning
Anyone who can write to the directory where Apache httpd is writing a log file can almost certainly gain access to the uid that the server is started as, which is normally root. Do NOT give people write access to the directory the logs are stored in without being aware of the consequences; see the security tips document for details.
In addition, log files may contain information supplied directly by the client, without escaping. Therefore, it is possible for malicious clients to insert control-characters in the log files, so care must be taken in dealing with raw logs.
Error Log
| Related Modules | Related Directives |
|---|---|
The server error log, whose name and location is set by the
ErrorLog directive, is the
most important log file. This is the place where Apache httpd
will send diagnostic information and record any errors that it
encounters in processing requests. It is the first place to
look when a problem occurs with starting the server or with the
operation of the server, since it will often contain details of
what went wrong and how to fix it.
The error log is usually written to a file (typically
error_log on Unix systems and
error.log on Windows and OS/2). On Unix systems it
is also possible to have the server send errors to
syslog or pipe them to a
program.
The format of the error log is defined by the ErrorLogFormat directive, with which you
can customize what values are logged. A default is format defined
if you don't specify one. A typical log message follows:
[Fri Sep 09 10:42:29.902022 2011] [core:error] [pid 35708:tid 4328636416]
[client 72.15.99.187] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error
The first item in the log entry is the date and time of the message. The next is the module producing the message (core, in this case) and the severity level of that message. This is followed by the process ID and, if appropriate, the thread ID, of the process that experienced the condition. Next, we have the client address that made the request. And finally is the detailed error message.
Note that some messages that were previously logged at
error level have been downgraded to info
level in httpd 2.4. For example, "File does not exist" messages
for 404 responses are logged at info level and will
not appear in the error log with the default
LogLevel of warn.
To restore the previous behavior, use
LogLevel warn core:info.
A very wide variety of different messages can appear in the
error log. Most look similar to the example above. The error
log will also contain debugging output from CGI scripts. Any
information written to stderr by a CGI script will
be copied directly to the error log.
Putting a %L token in both the error log and the access
log will produce a log entry ID with which you can correlate the entry
in the error log with the entry in the access log. If
mod_unique_id is loaded, its unique request ID will be
used as the log entry ID, too.
During testing, it is often useful to continuously monitor the error log for any problems. On Unix systems, you can accomplish this using:
tail -f error_log
Per-module logging
The LogLevel directive
allows you to specify a log severity level on a per-module basis. In
this way, if you are troubleshooting a problem with just one
particular module, you can turn up its logging volume without also
getting the details of other modules that you're not interested in.
This is particularly useful for modules such as
mod_proxy or mod_rewrite where you
want to know details about what it's trying to do.
Do this by specifying the name of the module in your
LogLevel directive:
LogLevel info rewrite:trace5
This sets the main LogLevel to info, but
turns it up to trace5 for
mod_rewrite.
RewriteLog, that were present in earlier versions of
the server.Access Log
| Related Modules | Related Directives |
|---|---|
The server access log records all requests processed by the
server. The location and content of the access log are
controlled by the CustomLog
directive. The LogFormat
directive can be used to simplify the selection of
the contents of the logs. This section describes how to configure the server
to record information in the access log.
Storing the information in the access log is only the start of log management. The next step is to analyze this information to produce useful statistics. Log analysis in general is beyond the scope of this document, and not really part of the job of the web server itself.
Various versions of Apache httpd have used other modules and
directives to control access logging, including
mod_log_referer, mod_log_agent, and the
TransferLog directive. The CustomLog directive now subsumes
the functionality of all the older directives.
The format of the access log is highly configurable. The format
is specified using a format string that looks much like a C-style
printf(1) format string. Some examples are presented in the next
sections. For a complete list of the possible contents of the
format string, see the mod_log_config format strings.
Common Log Format
A typical configuration for the access log might look as follows.
LogFormat "%h %l %u %t \"%r\" %>s %b" common CustomLog "logs/access_log" common
This defines the nickname common and
associates it with a particular log format string. The format
string consists of percent directives, each of which tell the
server to log a particular piece of information. Literal
characters may also be placed in the format string and will be
copied directly into the log output. The quote character
(") must be escaped by placing a backslash before
it to prevent it from being interpreted as the end of the
format string. The format string may also contain the special
control characters "\n" for new-line and
"\t" for tab.
The CustomLog
directive sets up a new log file using the defined
nickname. The filename for the access log is relative to
the ServerRoot unless it
begins with a slash.
The above configuration will write log entries in a format known as the Common Log Format (CLF). This standard format can be produced by many different web servers and read by many log analysis programs. The log file entries produced in CLF will look something like this:
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET
/apache_pb.gif HTTP/1.0" 200 2326
Each part of this log entry is described below.
127.0.0.1(%h)- This is the IP address of the client (remote host) which
made the request to the server. If
HostnameLookupsis set toOn, then the server will try to determine the hostname and log it in place of the IP address. However, this configuration is not recommended since it can significantly slow the server. Instead, it is best to use a log post-processor such aslogresolveto determine the hostnames. The IP address reported here is not necessarily the address of the machine at which the user is sitting. If a proxy server exists between the user and the server, this address will be the address of the proxy, rather than the originating machine. -(%l)- The "hyphen" in the output indicates that the requested
piece of information is not available. In this case, the
information that is not available is the RFC 1413 identity of
the client determined by
identdon the clients machine. This information is highly unreliable and should almost never be used except on tightly controlled internal networks. Apache httpd will not even attempt to determine this information unlessIdentityCheckis set toOn. frank(%u)- This is the userid of the person requesting the document
as determined by HTTP authentication. The same value is
typically provided to CGI scripts in the
REMOTE_USERenvironment variable. If the status code for the request (see below) is 401, then this value should not be trusted because the user is not yet authenticated. If the document is not password protected, this part will be "-" just like the previous one. [10/Oct/2000:13:55:36 -0700](%t)-
The time that the request was received.
The format is:
[day/month/year:hour:minute:second zone]
day = 2*digit
month = 3*letter
year = 4*digit
hour = 2*digit
minute = 2*digit
second = 2*digit
zone = (`+' | `-') 4*digitIt is possible to have the time displayed in another format by specifying
%{format}tin the log format string, whereformatis either as instrftime(3)from the C standard library, or one of the supported special tokens. For details see themod_log_configformat strings. "GET /apache_pb.gif HTTP/1.0"(\"%r\")- The request line from the client is given in double
quotes. The request line contains a great deal of useful
information. First, the method used by the client is
GET. Second, the client requested the resource/apache_pb.gif, and third, the client used the protocolHTTP/1.0. It is also possible to log one or more parts of the request line independently. For example, the format string "%m %U%q %H" will log the method, path, query-string, and protocol, resulting in exactly the same output as "%r". 200(%>s)- This is the status code that the server sends back to the client. This information is very valuable, because it reveals whether the request resulted in a successful response (codes beginning in 2), a redirection (codes beginning in 3), an error caused by the client (codes beginning in 4), or an error in the server (codes beginning in 5). The full list of possible status codes can be found in the HTTP specification (RFC 2616) (RFC2616 section 10).
2326(%b)- The last part indicates the size of the object returned
to the client, not including the response headers. If no
content was returned to the client, this value will be
"
-". To log "0" for no content, use%Binstead.
Combined Log Format
Another commonly used format string is called the Combined Log Format. It can be used as follows.
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog "log/access_log" combined
This format is exactly the same as the Common Log Format,
with the addition of two more fields. Each of the additional
fields uses the percent-directive
%{header}i, where header can be
any HTTP request header. The access log under this format will
look like:
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET
/apache_pb.gif HTTP/1.0" 200 2326
"http://www.example.com/start.html" "Mozilla/4.08 [en]
(Win98; I ;Nav)"
The additional fields are:
"http://www.example.com/start.html"(\"%{Referer}i\")- The "Referer" (sic) HTTP request header. This gives the
site that the client reports having been referred from. (This
should be the page that links to or includes
/apache_pb.gif). "Mozilla/4.08 [en] (Win98; I ;Nav)"(\"%{User-agent}i\")- The User-Agent HTTP request header. This is the identifying information that the client browser reports about itself.
Multiple Access Logs
Multiple access logs can be created simply by specifying
multiple CustomLog
directives in the configuration
file. For example, the following directives will create three
access logs. The first contains the basic CLF information,
while the second and third contain referer and browser
information. The last two CustomLog lines show how
to mimic the effects of the ReferLog and AgentLog directives.
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog "logs/access_log" common
CustomLog "logs/referer_log" "%{Referer}i -> %U"
CustomLog "logs/agent_log" "%{User-agent}i"
This example also shows that it is not necessary to define a
nickname with the LogFormat directive. Instead,
the log format can be specified directly in the CustomLog directive.
Conditional Logs
There are times when it is convenient to exclude certain
entries from the access logs based on characteristics of the
client request. This is easily accomplished with the help of environment variables. First, an
environment variable must be set to indicate that the request
meets certain conditions. This is usually accomplished with
SetEnvIf. Then the
env= clause of the CustomLog directive is used to
include or exclude requests where the environment variable is
set. Some examples:
# Mark requests from the loop-back interface SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog # Mark requests for the robots.txt file SetEnvIf Request_URI "^/robots\.txt$" dontlog # Log what remains CustomLog "logs/access_log" common env=!dontlog
As another example, consider logging requests from english-speakers to one log file, and non-english speakers to a different log file.
SetEnvIf Accept-Language "en" english CustomLog "logs/english_log" common env=english CustomLog "logs/non_english_log" common env=!english
In a caching scenario one would want to know about the efficiency of the cache. A very simple method to find this out would be:
SetEnv CACHE_MISS 1
LogFormat "%h %l %u %t "%r " %>s %b %{CACHE_MISS}e" common-cache
CustomLog "logs/access_log" common-cache
mod_cache will run before
mod_env and, when successful, will deliver the
content without it. In that case a cache hit will log
-, while a cache miss will log 1.
In addition to the env= syntax, LogFormat supports logging values
conditional upon the HTTP response code:
LogFormat "%400,501{User-agent}i" browserlog
LogFormat "%!200,304,302{Referer}i" refererlog
In the first example, the User-agent will be
logged if the HTTP status code is 400 or 501. In other cases, a
literal "-" will be logged instead. Likewise, in the second
example, the Referer will be logged if the HTTP
status code is not 200, 304, or 302. (Note the
"!" before the status codes.
Although we have just shown that conditional logging is very powerful and flexible, it is not the only way to control the contents of the logs. Log files are more useful when they contain a complete record of server activity. It is often easier to simply post-process the log files to remove requests that you do not want to consider.
Log Rotation
On even a moderately busy server, log files grow quickly — the access log typically grows 1 MB or more per 10,000 requests. Without rotation, logs consume disk space indefinitely and become unwieldy to analyze. You should set up automatic log rotation from the start.
Using rotatelogs (recommended)
The simplest approach is to use httpd's built-in
rotatelogs program via piped
logs. This rotates logs without requiring a server restart
and without any external tools. To rotate logs every 24 hours:
CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/httpd/access_log 86400" combined ErrorLog "|/usr/local/apache/bin/rotatelogs /var/log/httpd/error_log 86400"
To rotate when the log reaches a certain size (e.g., 100 MB):
CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/httpd/access_log 100M" combined
You can also use a time-based filename pattern with
strftime format strings:
CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/httpd/access_log.%Y-%m-%d 86400" combined
See rotatelogs for the full set of options,
including offset times, file count limits, and compression.
Using logrotate or system log management
Most Linux distributions include logrotate, which
can rotate, compress, and expire log files on a schedule. If your
distribution already ships an httpd logrotate configuration (check
/etc/logrotate.d/), it may already be handling rotation
for you.
When using an external rotation tool like logrotate,
you need to signal httpd to reopen its log files after
the old ones are moved aside. The standard approach is a
graceful restart:
/usr/sbin/apachectl graceful
Your logrotate configuration's postrotate script
should include this (or the equivalent
systemctl reload command). httpd continues writing to
the old file handle until it receives the signal, so any post-processing
of rotated files should allow a brief delay.
Piped Logs
httpd can write error and access log files through a pipe to
another process, rather than directly to a file. To use a piped
log, replace the filename with the pipe character
"|", followed by the command that should receive
log entries on its standard input:
CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/httpd/access_log 86400" combined
httpd starts the piped-log process at server startup and
restarts it automatically if it crashes (this is sometimes called
"reliable piped logging"). The quotes enclose the entire piped
command — this syntax works for both
CustomLog and
ErrorLog.
Piped log processes are spawned by the parent httpd process and inherit its userid. This typically means they run as root, so keep piped log programs simple and secure.
By default the piped log process is spawned directly, without
invoking a shell. Use "|$" instead of
"|" to spawn via a shell (usually
/bin/sh -c):
CustomLog "|$/usr/local/apache/bin/rotatelogs /var/log/httpd/access_log 86400" combined
The shell variant is occasionally needed if your piped command uses shell features like globbing or variable expansion. For most cases, the direct (non-shell) invocation is preferred.
Windows note
Note that on Windows, you may run into problems when running many piped
logger processes, especially when HTTPD is running as a service. This is
caused by running out of desktop heap space. The desktop heap space given
to each service is specified by the third argument to the
SharedSection parameter in the
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SessionManager\SubSystems\Windows
registry value. Change this value with care; the normal
caveats for changing the Windows registry apply, but you might also exhaust
the desktop heap pool if the number is adjusted too high.
Virtual Hosts
When running a server with many virtual
hosts, there are several options for dealing with log
files. First, it is possible to use logs exactly as in a
single-host server. Simply by placing the logging directives
outside the <VirtualHost> sections in the
main server context, it is possible to log all requests in the
same access log and error log. This technique does not allow
for easy collection of statistics on individual virtual
hosts.
If CustomLog
or ErrorLog
directives are placed inside a
<VirtualHost>
section, all requests or errors for that virtual host will be
logged only to the specified file. Any virtual host which does
not have logging directives will still have its requests sent
to the main server logs. This technique is very useful for a
small number of virtual hosts, but if the number of hosts is
very large, it can be complicated to manage. In addition, it
can often create problems with insufficient file
descriptors.
For the access log, there is a very good compromise. By adding information on the virtual host to the log format string, it is possible to log all hosts to the same log, and later split the log into individual files. For example, consider the following directives.
LogFormat "%v %p %h %l %u %t \"%r\" %>s %b" commonvhost CustomLog "logs/access_log" commonvhost
The %v is used to log the name of the virtual
host that is serving the request. Then a program like split-logfile can be used to
post-process the access log in order to split it into one file
per virtual host.
Other Log Files
| Related Modules | Related Directives |
|---|---|
Logging actual bytes sent and received
mod_logio adds in two additional
LogFormat fields
(%I and %O) that log the actual number of bytes received and sent
on the network.
Forensic Logging
mod_log_forensic provides for forensic logging of
client requests. Logging is done before and after processing a
request, so the forensic log contains two log lines for each
request. The forensic logger is very strict with no customizations.
It can be an invaluable debugging and security tool.
PID File
On startup, Apache httpd saves the process id of the parent
httpd process to the file logs/httpd.pid. This
filename can be changed with the PidFile directive. The
process-id is for use by the administrator in restarting and
terminating the daemon by sending signals to the parent
process; on Windows, use the -k command line option instead.
For more information see the Stopping
and Restarting page.
Script Log
In order to aid in debugging, the
ScriptLog directive
allows you to record the input to and output from CGI scripts.
This should only be used in testing - not for live servers.
More information is available in the mod_cgi documentation.
Configurable debug logging
The LogMessage
lets you create your own custom log messages to aid in debugging.
ملفات السجل
من أجل إدارة خادم الويب بفاعلية، من الضروري الحصول على معلومات حول نشاط الخادم وأدائه بالإضافة إلى أي مشكلات قد تحدث. يوفر خادم Apache HTTP إمكانيات تسجيل شاملة ومرنة للغاية. يوضح هذا المستند كيفية تكوين إمكانيات التسجيل الخاصة به، وكيفية فهم ما تحتوي عليه السجلات.
نظرة عامة
| الوحدات ذات الصلة | التوجيهات ذات الصلة |
|---|---|
يوفر خادم Apache HTTP مجموعة متنوعة من الآليات المختلفة لتسجيل كل ما يحدث على الخادم الخاص بك، بدءًا من الطلب الأولي، مرورًا بعملية تعيين عنوان URL، وحتى الحل النهائي للاتصال، بما في ذلك أي أخطاء قد تكون حدثت في هذه العملية. بالإضافة إلى ذلك، قد توفر وحدات الجهات الخارجية إمكانيات تسجيل، أو تدرج إدخالات في ملفات السجل الحالية، وقد ترسل التطبيقات مثل برامج CGI، أو نصوص PHP البرمجية، أو المعالجات الأخرى، رسائل إلى سجل أخطاء الخادم.
نناقش في هذا المستند وحدات التسجيل التي تشكل جزءًا قياسيًا من خادم http.
تحذير أمني
أي شخص يمكنه الكتابة إلى الدليل الذي يكتب فيه Apache httpd ملف سجل، يمكنه بالتأكيد تقريبًا الحصول على إمكانية الوصول إلى المعرف uid الذي يتم تشغيل الخادم به، والذي يكون عادةً root. لا تَقُمْ بإعطاء الأشخاص صلاحية الكتابة إلى الدليل الذي تُخزن فيه السجلات دون أن تكون مدركًا للعواقب؛ راجع نصائح الأمان المستند للحصول على التفاصيل.
بالإضافة إلى ذلك، قد تحتوي ملفات السجل على معلومات مُقدمة مباشرةً من العميل، دون إفلات. لذلك، يُمكن للعملاء الخبثاء إدراج أحرف تحكم في ملفات السجل، لذا يجب توخي الحذر عند التعامل مع السجلات الخام.
سجل الأخطاء
| الوحدات النمطية ذات الصلة | التوجيهات ذات الصلة |
|---|---|
سجل أخطاء الخادم، الذي يُحدد اسمه وموقعه بوساطة التوجيه
ErrorLog ، هو أهم ملف سجل. هذا هو المكان الذي سيرسل إليه Apache httpd المعلومات التشخيصية ويسجل أي أخطاء يواجهها في معالجة الطلبات. وهو أول مكان يُنظر فيه عند حدوث مشكلة في بدء تشغيل الخادم أو في تشغيله، نظرًا لأنه سيتضمن غالبًا تفاصيل عما حدث من خطأ وكيفية إصلاحه.
عادةً ما يُكتب سجل الأخطاء إلى ملف (عادةً
error_log على أنظمة Unix و
error.log على Windows و OS/2). في أنظمة Unix، يُمكن أيضًا جعل الخادم يرسل الأخطاء إلى
syslog أو تمريرها عبر أنبوب إلى
برنامج.
يُحدَّد تنسيق سجل الأخطاء بواسطة التوجيه ErrorLogFormat، والذي يمكنك من خلاله تخصيص القيم التي يتم تسجيلها. ويُحدَّد تنسيق افتراضي إذا لم تحدد تنسيقًا. وتلي ذلك رسالة سجل نموذجية:
[Fri Sep 09 10:42:29.902022 2011] [core:error] [pid 35708:tid 4328636416]
[client 72.15.99.187] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error
العنصر الأول في مدخلة السجل هو تاريخ الرسالة ووقتها. والعنصر التالي هو الوحدة المخرجة للرسالة (core، في هذه الحالة) ومستوى خطورة تلك الرسالة. ويتبع ذلك معرف العملية (process ID) ومعرف السلسلة (thread ID) للعملية التي واجهت الحالة، إذا كان ذلك مناسبًا. بعد ذلك، لدينا عنوان العميل الذي أجرى الطلب. وأخيرًا رسالة الخطأ التفصيلية.
لاحظ أن بعض الرسائل التي تم تسجيلها سابقًا عند المستوى error قد تم تخفيضها إلى المستوى info في httpd 2.4. على سبيل المثال، تُسجَّل رسائل "File does not exist" لردود 404 عند المستوى info ولن تظهر في سجل الأخطاء مع الإعداد الافتراضي لـ LogLevel وهو warn. ولإعادة السلوك السابق، استخدم LogLevel warn core:info.
يمكن أن تظهر مجموعة واسعة جدًا من الرسائل المختلفة في سجل الأخطاء. ويشبه معظمها المثال أعلاه. وسيحتوي سجل الأخطاء أيضًا على مخرجات تصحيح الأخطاء من نصوص CGI البرمجية. أي معلومات مكتوبة إلى stderr بواسطة نص برمجي لـ CGI ستُنسخ مباشرة إلى سجل الأخطاء.
وضع %L الرمز في كل من سجل الأخطاء وسجل الوصول سينتج معرف إدخال سجل يمكنك من خلاله الربط بين الإدخال في سجل الأخطاء والإدخال في سجل الوصول. إذا mod_unique_idمُحمَّلاً، سيُستخدم معرّف الطلب الفريد الخاص به كمعرّف لإدخال السجل أيضاً.
أثناء الاختبار، غالباً ما يكون من المفيد مراقبة سجل الأخطاء باستمرار لرصد أي مشكلات. في أنظمة Unix، يمكنك تحقيق ذلك باستخدام:
tail -f error_log
التسجيل لكل وحدة
تتيح توجيهة LogLevel تحديد مستوى شدة السجل على أساس كل وحدة على حدة. وبهذه الطريقة، إذا كنت تقوم باستكشاف مشكلة وإصلاحها في وحدة معينة فقط، فيمكنك زيادة حجم التسجيل الخاص بها دون الحصول أيضاً على تفاصيل الوحدات الأخرى التي لا تهمك. وهذا مفيد بشكل خاص لوحدات مثل mod_proxy أو mod_rewrite حيث تريد معرفة التفاصيل عما تحاول القيام به.
قم بذلك عن طريق تحديد اسم الوحدة في توجيهة LogLevel الخاصة بك:
LogLevel info rewrite:trace5
يضبط هذا LogLevel الرئيسي على info، ولكنه يرفعه إلى trace5 لـ
mod_rewrite.
RewriteLog، التي كانت موجودة في الإصدارات السابقة من
الخادم.سجل الوصول
| الوحدات ذات الصلة | التوجيهات ذات الصلة |
|---|---|
يسجل سجل وصول الخادم جميع الطلبات التي يعالجها
الخادم. ويتم التحكم في موقع سجل الوصول ومحتواه بواسطة
توجيه CustomLog
. ويمكن استخدام توجيه
LogFormat
لتسهيل تحديد محتويات السجلات. ويوضح هذا القسم كيفية تكوين الخادم
لتسجيل المعلومات في سجل الوصول.
إن تخزين المعلومات في سجل الوصول ليس سوى بداية إدارة السجلات. والخطوة التالية هي تحليل هذه المعلومات لإنتاج إحصاءات مفيدة. يُعد تحليل السجلات عمومًا خارج نطاق هذا المستند، وليس جزءًا فعليًا من مهمة خادم الويب نفسه.
استخدمت إصدارات مختلفة من Apache httpd وحدات وتوجيهات أخرى للتحكم في تسجيل الوصول، بما في ذلك mod_log_referer و mod_log_agent وTransferLog التوجيه. والتوجيه CustomLog الآن يتضمن وظائف جميع التوجيهات القديمة.
تنسيق سجل الوصول قابل للتهيئة بدرجة كبيرة. ويتم تحديد التنسيق باستخدام سلسلة تنسيق تشبه إلى حد كبير سلسلة التنسيق لـ printf(1) بأسلوب لغة C. تُعرض بعض الأمثلة في الأقسام التالية. للحصول على قائمة كاملة بالمحتويات المحتملة لسلسلة التنسيق، انظر mod_log_config سلاسل التنسيق.
تنسيق السجل المشترك
قد يبدو التكوين النموذجي لسجل الوصول على النحو التالي.
LogFormat "%h %l %u %t \"%r\" %>s %b" common CustomLog "logs/access_log" common
يحدد هذا الاسم المستعار common ويربطه بسلسلة نصية محددة لتنسيق السجل. تتكون سلسلة التنسيق النصية من توجيهات علامة النسبة المئوية، ويطلب كل منها من الخادم تسجيل جزء معين من المعلومات. يمكن أيضًا وضع الأحرف الحرفية في سلسلة التنسيق النصية وسيتم نسخها مباشرة إلى مخرجات السجل. رمز الاقتباس (") يجب الهروب منه بوضع شرطة مائلة عكسية قبله لمنع تفسيره على أنه نهاية سلسلة التنسيق. قد تحتوي سلسلة التنسيق أيضًا على أحرف التحكم الخاصة "\n" للسطر الجديد و"\t" للجدولة.
يقوم CustomLogالتوجيه بإعداد ملف سجل جديد باستخدام الاسم المستعار المحدد. ويكون اسم الملف الخاص بسجل الوصول نسبيًا إلى ServerRoot ما لم يبدأ بشرطة مائلة.
سيكتب التكوين أعلاه إدخالات السجل بتنسيق يُعرف باسم تنسيق السجل المشترك (CLF). يمكن إنتاج هذا التنسيق القياسي بواسطة العديد من خوادم الويب المختلفة وقراءته بواسطة العديد من برامج تحليل السجلات. ستكون إدخالات ملف السجل الناتجة بتنسيق CLF مشابهة لهذا:
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET
/apache_pb.gif HTTP/1.0" 200 2326
تم توضيح كل جزء من إدخال السجل هذا أدناه.
127.0.0.1(%h)- هذا هو عنوان IP الخاص بالعميل (المضيف البعيد) الذي أرسل الطلب إلى الخادم. إذا تم ضبط
HostnameLookupsعلىOn، فسوف يحاول الخادم تحديد اسم المضيف وتسجيله بدلاً من عنوان IP. ومع ذلك، لا يُوصى بهذا التكوين لأنه يمكن أن يبطئ الخادم بشكل كبير. وبدلاً من ذلك، يُفضل استخدام معالج لاحق للسجلات مثلlogresolveلتحديد أسماء المضيفين. وعنوان IP المسجل هنا ليس بالضرورة عنوان الجهاز الذي يجلس عليه المستخدم. وإذا كان هناك خادم وكيل بين المستخدم والخادم، فسيكون هذا العنوان هو عنوان الخادم الوكيل وليس الجهاز المصدر. -(%l)- تشير "الشرطة" في المخرجات إلى أن المعلومة المطلوبة غير متاحة. وفي هذه الحالة، فإن المعلومة غير المتاحة هي هوية RFC 1413 للعميل التي يُحددها
identdعلى جهاز العميل. وهذه المعلومات غير موثوقة للغاية ولا ينبغي استخدامها تقريباً إلا في الشبكات الداخلية الخاضعة للتحكم الصارم. ولن يحاول Apache httpd حتى تحديد هذه المعلومات ما لم يتم ضبطIdentityCheckعلىOn. frank(%u)- هذا هو معرف المستخدم للشخص الذي يطلب المستند
وفقًا لما تحدده مصادقة HTTP. وعادةً ما تُقدَّم القيمة نفسها
إلى برامج CGI النصية في
REMOTE_USERمتغير البيئة. إذا كان رمز الحالة للطلب (انظر أدناه) هو 401، فلا ينبغي الوثوق بهذه القيمة لأن المستخدم لم تتم مصادقته بعد. إذا لم يكن المستند محميًا بكلمة مرور، فسيكون هذا الجزء "-" تمامًا مثل الجزء السابق. [10/Oct/2000:13:55:36 -0700](%t)-
الوقت الذي تم استلام الطلب فيه.
والصيغة هي:
[day/month/year:hour:minute:second zone]
day = 2*digit
month = 3*letter
year = 4*digit
hour = 2*digit
minute = 2*digit
second = 2*digit
zone = (`+' | `-') 4*digitمن الممكن عرض الوقت بتنسيق آخر من خلال تحديد
%{format}tفي سلسلة تنسيق السجل، حيثformatإما كما فيstrftime(3)من مكتبة C القياسية، أو أحد الرموز الخاصة المدعومة. لمزيد من التفاصيل، انظرmod_log_configسلاسل التنسيق. "GET /apache_pb.gif HTTP/1.0"(\"%r\")- سطر الطلب الوارد من العميل معروض بين علامتي تنصيص مزدوجتين. يحتوي سطر الطلب على قدر كبير من المعلومات المفيدة. أولاً، الطريقة التي استخدمها العميل هي
GET. ثانياً، طلب العميل المورد/apache_pb.gif، وثالثاً، استخدم العميل البروتوكولHTTP/1.0. من الممكن أيضاً تسجيل جزء أو أكثر من سطر الطلب بشكل مستقل. على سبيل المثال، نص التنسيق "%m %U%q %H" سيسجل الطريقة والمسار وسلسلة الاستعلام والبروتوكول، مما يؤدي إلى نفس المخرجات تمامًا مثل "%r". 200(%>s)- هذا هو رمز الحالة الذي يرسله الخادم إلى العميل. وتعد هذه المعلومات قيمة للغاية، لأنها تكشف عما إذا كان الطلب قد أسفر عن استجابة ناجحة (الرموز التي تبدأ بـ 2)، أو إعادة توجيه (الرموز التي تبدأ بـ 3)، أو خطأ تسبب فيه العميل (الرموز التي تبدأ بـ 4)، أو خطأ في الخادم (الرموز التي تبدأ بـ 5). ويمكن العثور على القائمة الكاملة لرموز الحالة المحتملة في مواصفات HTTP (RFC 2616) (RFC2616 القسم 10).
2326(%b)- يشير الجزء الأخير إلى حجم الكائن المرجع إلى العميل، دون تضمين ترويسات الاستجابة. إذا لم يتم إرجاع أي محتوى إلى العميل، فستكون هذه القيمة "
-". لتسجيل "0" في حال عدم وجود محتوى، استخدم%Bبدلاً من ذلك.
تنسيق السجل المدمج
تُسمى سلسلة تنسيق أخرى شائعة الاستخدام بتنسيق السجل المدمج. ويمكن استخدامها على النحو التالي.
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog "log/access_log" combined
هذا التنسيق هو نفسه تمامًا مثل تنسيق السجل المشترك، مع إضافة حقلين آخرين. يستخدم كل حقل من الحقول الإضافية توجيه النسبة المئوية %{header}i، حيث ترويسةيمكن أن يكون أي رأس طلب HTTP. سيبدو سجل الوصول بهذا التنسيق كما يلي:
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET
/apache_pb.gif HTTP/1.0" 200 2326
"http://www.example.com/start.html" "Mozilla/4.08 [en]
(Win98; I ;Nav)"
الحقول الإضافية هي:
"http://www.example.com/start.html"(\"%{Referer}i\")- رأس طلب HTTP المعنون "Referer" (كما وردت). ويعطي هذا الموقع الذي يذكر العميل أنه أحيل منه. (وينبغي أن تكون هذه هي الصفحة التي ترتبط بـ أو تتضمن
/apache_pb.gif). "Mozilla/4.08 [en] (Win98; I ;Nav)"(\"%{User-agent}i\")- رأس طلب HTTP المعنون User-Agent. هذه هي معلومات التعريف التي يذكرها متصفح العميل عن نفسه.
سجلات وصول متعددة
يمكن إنشاء سجلات وصول متعددة ببساطة عن طريق تحديد عدة CustomLogتوجيهات في ملف التكوين. على سبيل المثال، ستنشئ التوجيهات التالية ثلاثة سجلات وصول. يحتوي الأول على معلومات CLF الأساسية، بينما يحتوي الثاني والثالث على معلومات المرجع والمتصفح. والأخيران CustomLogتوضح الأسطر كيفية محاكاة تأثيرات التوجيهين ReferLog و AgentLog.
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog "logs/access_log" common
CustomLog "logs/referer_log" "%{Referer}i -> %U"
CustomLog "logs/agent_log" "%{User-agent}i"
يوضح هذا المثال أيضًا أنه ليس من الضروري تعريف اسم مستعار باستخدام التوجيه LogFormat. وبدلاً من ذلك، يمكن تحديد صيغة السجل مباشرة في التوجيه CustomLog.
السجلات الشرطية
هناك أوقات يكون فيها من المناسب استبعاد إدخالات معينة من سجلات الوصول بناءً على خصائص طلب العميل. وتتحقق هذه العملية بسهولة بمساعدة متغيرات البيئة. أولاً، يجب تعيين متغير بيئة للإشارة إلى أن الطلب يستوفي شروطًا معينة. ويتم ذلك عادةً باستخدام SetEnvIf. ثم تُستخدم العبارة env= الخاصة بـ CustomLog تُستخدم التوجيهة لتضمين الطلبات أو استبعادها عندما يكون متغير البيئة محددًا. بعض الأمثلة:
# Mark requests from the loop-back interface SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog # Mark requests for the robots.txt file SetEnvIf Request_URI "^/robots\.txt$" dontlog # Log what remains CustomLog "logs/access_log" common env=!dontlog
كمثال آخر، يُرجى النظر في تسجيل الطلبات من المتحدثين بالإنجليزية في ملف سجل واحد، والمتحدثين بغير الإنجليزية في ملف سجل مختلف.
SetEnvIf Accept-Language "en" english CustomLog "logs/english_log" common env=english CustomLog "logs/non_english_log" common env=!english
في سيناريو التخزين المؤقت، قد يرغب المرء في معرفة كفاءة ذاكرة التخزين المؤقت. وتتمثل طريقة بسيطة جداً لاكتشاف ذلك في:
SetEnv CACHE_MISS 1
LogFormat "%h %l %u %t "%r " %>s %b %{CACHE_MISS}e" common-cache
CustomLog "logs/access_log" common-cache
mod_cache سيعمل قبل mod_env وعند النجاح، سيعمل على تسليم المحتوى بدونه. وفي تلك الحالة، ستسجّل إصابة التخزين المؤقت -، بينما سيسجّل إخفاق التخزين المؤقت 1.
بالإضافة إلى env= بناء الجملة، LogFormat يدعم تسجيل القيم بشكل مشروط برمز استجابة HTTP:
LogFormat "%400,501{User-agent}i" browserlog
LogFormat "%!200,304,302{Referer}i" refererlog
في المثال الأول، User-agentسيُسجَّل إذا كان رمز حالة HTTP هو 400 أو 501. وفي الحالات الأخرى، سيُسجَّل الحرف "-" حرفياً بدلاً من ذلك. وبالمثل، في المثال الثاني، Referer سيتم تسجيله إذا كان رمز حالة HTTP هو ليس 200 أو 304 أو 302. (لاحظ وجود "!" قبل رموز الحالة.
على الرغم من أننا أظهرنا للتو أن التسجيل الشرطي قوي للغاية ومرن، إلا أنه ليس الطريقة الوحيدة للتحكم في محتويات السجلات. تكون ملفات السجل أكثر فائدة عندما تحتوي على سجل كامل لنشاط الخادم. وغالباً ما يكون من الأسهل معالجة ملفات السجل لاحقاً لإزالة الطلبات التي لا تريد أخذها بعين الاعتبار.
تدوير السجلات
حتى على الخادم متوسط النشاط، تنمو ملفات السجل بسرعة — حيث ينمو سجل الوصول عادةً بمقدار 1 ميغابايت أو أكثر لكل 10,000 طلب. وبدون التدوير، تستهلك السجلات مساحة القرص بشكل غير محدود وتصبح معالجة تحليلاتها صعبة. يجب عليك إعداد تدوير تلقائي للسجلات منذ البداية.
استخدام rotatelogs (موصى به)
النهج الأبسط هو استخدام أداة httpd المدمجة rotatelogsبرنامج عبر السجلات الموجهة عبر أنابيب. يؤدي هذا إلى تدوير السجلات دون الحاجة إلى إعادة تشغيل الخادم ودون أي أدوات خارجية. لتدوير السجلات كل 24 ساعة:
CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/httpd/access_log 86400" combined ErrorLog "|/usr/local/apache/bin/rotatelogs /var/log/httpd/error_log 86400"
للتدوير عندما يصل السجل إلى حجم معين (على سبيل المثال، 100 ميجابايت):
CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/httpd/access_log 100M" combined
يمكنك أيضاً استخدام نمط اسم ملف يعتمد على الوقت مع strftime سلاسل التنسيق:
CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/httpd/access_log.%Y-%m-%d 86400" combined
راجع rotatelogs للاطلاع على المجموعة الكاملة من الخيارات، بما في ذلك أوقات الإزاحة، والحدود القصوى لعدد الملفات، والضغط.
استخدام logrotate أو إدارة سجلات النظام
تتضمن معظم توزيعات Linux logrotate، والتي يمكنها تدوير ملفات السجل وضغطها وإنهاء صلاحيتها وفق جدول زمني. إذا كانت توزيعتك تتضمن بالفعل تكوين logrotate لـ httpd (تحقق من /etc/logrotate.d/)، فقد تكون تتولى بالفعل معالجة التدوير لصالحك.
عند استخدام أداة تدوير خارجية مثل logrotate، تحتاج إلى إرسال إشارة إلى httpd لإعادة فتح ملفات السجل الخاصة به بعد نقل الملفات القديمة جانباً. والنهج القياسي هو إجراء إعادة تشغيل هادئة :
/usr/sbin/apachectl graceful
يجب أن يتضمن سكريبت postrotate الخاص بتكوين logrotate لديك هذا (أو أمر systemctl reload المكافئ). يستمر httpd في الكتابة إلى مقبض الملف القديم حتى يتلقى الإشارة، لذا فإن أي معالجة لاحقة للملفات المدورة يجب أن تسمح بتأخير قصير.
السجلات الموجهة عبر الأنابيب
يمكن لـ httpd كتابة ملفات سجل الأخطاء والوصول عبر أنبوب إلى عملية أخرى، بدلاً من كتابتها مباشرة في ملف. لاستخدام سجل موجه عبر أنبوب، استبدل اسم الملف برمز الأنبوب "|"، متبوعاً بالأمر الذي يجب أن يستقبل إدخالات السجل على دخله القياسي:
CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/httpd/access_log 86400" combined
يبدأ httpd عملية السجلات الموجهة عند بدء تشغيل الخادم ويعيد تشغيلها تلقائيًا إذا تعطلت (يُطلق على هذا أحيانًا "تسجيل السجلات الموجه الموثوق"). تحيط علامات الاقتباس بالأمر الموجه بالكامل — وتعمل هذه الصيغة مع كل من CustomLog و ErrorLog.
تُنشأ عمليات السجلات الموجهة بواسطة عملية httpd الأصلية وترث معرف المستخدم الخاص بها. يعني هذا عادةً أنها تعمل بصفة root، لذا احرص على أن تكون برامج السجلات الموجهة بسيطة وآمنة.
بشكل افتراضي تُنشأ عملية السجل الموجه مباشرة، دون استدعاء غلاف أوامر (shell). استخدم "|$" بدلاً من "|" للبدء عبر موجه الأوامر (عادةً
/bin/sh -c):
CustomLog "|$/usr/local/apache/bin/rotatelogs /var/log/httpd/access_log 86400" combined
يلزم استخدام خيار موجه الأوامر أحيانًا إذا كان الأمر الموجه عبر الأنبوب يستخدم ميزات موجه الأوامر مثل المطابقة المجمعة أو توسيع المتغيرات. في معظم الحالات، يُفضل الاستدعاء المباشر (من دون موجه الأوامر).
ملاحظة بشأن Windows
لاحظ أنه في نظام Windows، قد تواجه مشكلات عند تشغيل العديد من عمليات
سجل البيانات الموجهة عبر الأنبوب، لا سيما عندما يعمل HTTPD كخدمة. وينتج هذا
عن نفاد مساحة ذاكرة الكومة لسطح المكتب. وتُحدد مساحة ذاكرة الكومة لسطح المكتب الممنوحة
لكل خدمة بواسطة الوسيط الثالث لـ
SharedSection المعلمة في قيمة السجل
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SessionManager\SubSystems\Windows. غيّر هذه القيمة بحذر؛ تنطبق التحذيرات المعتادة الخاصة بتغيير سجل Windows، ولكنك قد تستنفد أيضًا مجمع كومة سطح المكتب إذا تم ضبط الرقم بزيادة كبيرة.
المضيفات الافتراضية
عند تشغيل خادم يتضمن العديد من المضيفات الافتراضية، تتوفر عدة خيارات للتعامل مع ملفات السجل. أولاً، من الممكن استخدام السجلات تمامًا كما هو الحال في خادم بمضيف واحد. ببساطة عن طريق وضع توجيهات التسجيل خارج <VirtualHost> الأقسام في سياق الخادم الرئيسي، من الممكن تسجيل جميع الطلبات في سجل الوصول وسجل الأخطاء نفسهما. لا تتيح هذه التقنية جمع الإحصاءات بسهولة لكل مضيف افتراضي على حدة.
إذا CustomLog
أو ErrorLog
وضعت توجيهات داخل
<VirtualHost>
قسم، فستُسجَّل جميع الطلبات أو الأخطاء الخاصة بذلك المضيف الافتراضي في الملف المحدد فقط. وأي مضيف افتراضي لا يحتوي على توجيهات تسجيل ستظل طلباته تُرسَل إلى سجلات الخادم الرئيسي. هذه التقنية مفيدة جداً لعدد صغير من المضيفين الافتراضيين، ولكن إذا كان عدد المضيفين كبيراً جداً، فقد يكون من المعقد إدارتها. بالإضافة إلى ذلك، يمكن أن تتسبب غالباً في مشاكل تتعلق بـ عدم كفاية واصفات
الملفات.
بالنسبة لسجل الوصول، هناك حل وسط جيد جداً. فمن خلال إضافة معلومات عن المضيف الافتراضي إلى سلسلة صيغة السجل، يمكن تسجيل جميع المضيفين في السجل نفسه، ثم تقسيم السجل لاحقاً إلى ملفات منفصلة. على سبيل المثال، تأمل التوجيهات التالية.
LogFormat "%v %p %h %l %u %t \"%r\" %>s %b" commonvhost CustomLog "logs/access_log" commonvhost
يُستخدم %v لتسجيل اسم المضيف الافتراضي الذي يخدم الطلب. وعندئذٍ يمكن استخدام برنامج مثل split-logfile لمعالجة سجل الوصول لاحقاً من أجل تقسيمه إلى ملف واحد لكل مضيف افتراضي.
ملفات السجلات الأخرى
| الوحدات ذات الصلة | التوجيهات ذات الصلة |
|---|---|
تسجيل البايتات الفعلية المرسلة والمستلمة
mod_logio يضيف حقلين إضافيين LogFormat (%I و%O) يسجلان العدد الفعلي للبايتات المستلمة والمرسلة عبر الشبكة.
التسجيل الجنائي
mod_log_forensic يوفر التسجيل الجنائي لطلبات العملاء. يتم التسجيل قبل معالجة الطلب وبعدها، لذا يحتوي السجل الجنائي على سطرين لكل طلب. إن نظام التسجيل الجنائي صارم للغاية ولا يسمح بأي تخصيصات. ويمكن أن يكون أداة قيمة للغاية لتصحيح الأخطاء وتعزيز الأمان.
ملف PID
عند بدء التشغيل، يحفظ Apache httpd معرف العملية للعملية الرئيسية httpd في الملف logs/httpd.pid. يمكن تغيير اسم الملف هذا باستخدام التوجيه PidFile. معرف العملية مخصص لاستخدام المسؤول في إعادة تشغيل الخادم الخفي وإنهائه عن طريق إرسال إشارات إلى العملية الرئيسية؛ وفي نظام Windows، استخدم خيار سطر الأوامر -k بدلاً من ذلك. لمزيد من المعلومات، راجع الإيقاف وإعادة التشغيل الصفحة.
سجل البرامج النصية
من أجل المساعدة في تصحيح الأخطاء، يتيح التوجيه ScriptLog تسجيل المدخلات والمخرجات لبرامج CGI النصية. يجب استخدام هذا في الاختبار فقط - وليس للخوادم الحية. تتوفر المزيد من المعلومات في mod_cgi التوثيق.
تسجيل تصحيح الأخطاء القابل للتكوين
الـ LogMessageيتيح لك إنشاء رسائل سجل مخصصة خاصة بك للمساعدة في تصحيح الأخطاء.
Frequently asked questions · الأسئلة الشائعة
What is the primary purpose of the Apache HTTP Server Error Log?ما هو الغرض الأساسي من سجل الأخطاء في خادم أباتشي HTTP؟
The Error Log, configured via the ErrorLog directive, is the main diagnostic file where Apache httpd records error messages and operational problems encountered during request processing or server startup.
يُعد سجل الأخطاء، المكوّن عبر التوجيه ErrorLog، ملف التشخيص الرئيسي الذي يسجل فيه خادم أباتشي HTTP رسائل الأخطاء والمشكلات التشغيلية أثناء معالجة الطلبات أو بدء التشغيل.
Which standard modules are used to manage and configure logging in Apache HTTP Server?ما هي الوحدات النمطية القياسية المستخدمة لإدارة وإعداد التسجيل في خادم أباتشي HTTP؟
The standard modules provided by Apache HTTP Server for managing logging capabilities include mod_log_config, mod_log_forensic, mod_logio, mod_cgi, and core directives.
تشمل الوحدات النمطية القياسية التي يوفرها خادم أباتشي HTTP لإدارة إمكانيات التسجيل كلاً من mod_log_config وmod_log_forensic وmod_logio وmod_cgi بالإضافة إلى توجيهات النواة core.
What requirement must be met to correlate entries between the error log and the access log?ما هي المتطلبات الأساسية للربط بين إدخالات سجل الأخطاء وسجل الوصول؟
To correlate entries between the error log and access log, you must include the %L token in both log formats, or load the mod_unique_id module to generate a unique request ID.
للربط بين إدخالات سجل الأخطاء وسجل الوصول، يجب تضمين الرمز %L في كلي صيغتي التسجيل، أو تحميل الوحدة النمطية mod_unique_id لتوليد معرف طلب فريد.
What security risks are associated with log file directory permissions and raw log entries?ما هي المخاطر الأمنية المرتبطة بأذونات دليل ملفات السجل وإدخالات السجلات الخام؟
Granting write access to the log directory allows unauthorized users to potentially gain root-level access. Additionally, unescaped control-characters inserted by malicious clients in raw logs present security risks.
منح صلاحية الكتابة لدليل السجلات قد يمكن المستخدمين غير المصرح لهم من الوصول إلى صلاحيات الجذر root. بالإضافة إلى ذلك، يمكن للعملاء الخبثاء إدراج أحرف تحكم غير معالجة في السجلات الخام مما يشكل خطراً أمنياً.
How can an administrator set up a custom access log format using directives?كيف يمكن للمسؤول إعداد صيغة مخصصة لسجل الوصول باستخدام التوجيهات؟
An administrator uses the LogFormat directive to define a format string with a nickname, and then applies the CustomLog directive to specify the log file path and the assigned nickname.
يقوم المسؤول باستخدام التوجيه LogFormat لتحديد سلسلة الصيغة وتعيين اسم مستعار لها، ثم يستخدم التوجيه CustomLog لتحديد مسار ملف السجل والاسم المستعار المعين.
How can an administrator continuously validate log output during testing on Unix systems?كيف يمكن للمسؤول التحقق المستمر من مخرجات السجل أثناء الاختبار على أنظمة يونكس؟
On Unix systems, administrators can continuously monitor real-time error log output during testing by running the command tail -f error_log in the terminal.
على أنظمة يونكس، يمكن للمسؤولين مراقبة مخرجات سجل الأخطاء فورياً وبشكل مستمر أثناء الاختبار عن طريق تشغيل الأمر tail -f error_log في الطرفية.
How do you troubleshoot specific module behavior without increasing overall server log volume?كيف تقوم باستكشاف أخطاء وحدة نمطية محددة وإصلاحها دون زيادة حجم السجل الإجمالي للخادم؟
You can use the LogLevel directive to adjust verbosity on a per-module basis, such as specifying LogLevel info rewrite:trace5 to isolate mod_rewrite details without generating excess core logging.
يمكنك استخدام التوجيه LogLevel لضبط مستوى التفصيل لكل وحدة نمطية بشكل منفصل، مثل تحديد LogLevel info rewrite:trace5 لعزل تفاصيل mod_rewrite دون توليد سجلات زائدة للنواة.
Why might 404 File does not exist errors disappear after upgrading to httpd 2.4, and how is this handled?لماذا قد تختفي أخطاء 404 File does not exist بعد الترقية إلى httpd 2.4 وكيف يتم التعامل معها؟
In httpd 2.4, 404 messages were downgraded from error to info level, which hides them under default LogLevel warn settings; to escalate visibility, set LogLevel warn core:info.
في الإصدار httpd 2.4، تم خفض مستوى رسائل 404 من error إلى info، مما يخفيها تحت إعدادات LogLevel warn الافتراضية؛ ولإعادة إظهارها يجب ضبط LogLevel warn core:info.
How does client IP logging in access logs apply to infrastructure monitoring across regional networks?كيف ينطبق تسجيل عنوان IP للعميل في سجلات الوصول على مراقبة البنية التحتية عبر شبكات المناطق؟
Access logs record client IP addresses (%h) for all requests, providing regional network visibility without slowing server performance compared to enabling HostnameLookups.
تسجل سجلات الوصول عناوين IP الخاصة بالعملاء (%h) لكل الطلبات، مما يوفر رؤية شبكية إقليمية دون إبطاء أداء الخادم مقارنة بتفعيل HostnameLookups.
What is the recommended next action for analyzing access log data after recording has been configured?ما هو الإجراء التالي الموصى به لتحليل بيانات سجل الوصول بعد إعداد التسجيل؟
After configuring access logging, the next action is to run log post-processing or external log analysis tools on the stored log files to process statistics and resolve IP hostnames.
بعد إعداد تسجيل الوصول، يتمثل الإجراء التالي في تشغيل أدوات معالجة السجلات البعدية أو أدوات التحليل الخارجية على ملفات السجل المخزنة لمعالجة الإحصائيات وتحليل أسماء مضيفي IP.
Related reading
Knowledge base
Apache HTTP Server Tutorial: .htaccess filesKnowledge base
Getting StartedKnowledge base
Name-based Virtual Host SupportArticle
WordPress Hosting for High Traffic in KSA, GCC & MENA: The Technical Playbook (Arabic + English Sites)Technical WordPress hosting guide for KSA/GCC/MENA: caching stack, Redis, database tuning, NVMe, WAF/bot control, Core Web Vitals, and scaling to dedicated or cloud.
Article
Website Migration to a KSA Data Center: The Zero-Downtime Technical Playbook (GCC & MENA)Migrate to a KSA data center with zero downtime: staging checks, DNS TTL plan, DB sync, SSL, email, SEO safety, rollback, monitoring. Saudi, GCC MENA.