Where is apache2 log




















Likewise, in the second example, the Referer will be logged if the HTTP status code is not , , or Note the "! 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.

On even a moderately busy server, the quantity of information stored in the log files is very large. The access log file typically grows 1 MB or more per 10, requests. It will consequently be necessary to periodically rotate the log files by moving or deleting the existing logs. This cannot be done while the server is running, because Apache httpd will continue writing to the old log file as long as it holds the file open.

Instead, the server must be restarted after the log files are moved or deleted so that it will open new log files. By using a graceful restart, the server can be instructed to open new log files without losing any existing or pending connections from clients.

However, in order to accomplish this, the server must continue to write to the old log files while it finishes serving old requests. It is therefore necessary to wait for some time after the restart before doing any processing on the log files. A typical scenario that simply rotates the logs and compresses the old logs to save space is:. Another way to perform log rotation is using piped logs as discussed in the next section.

Apache httpd is capable of writing error and access log files through a pipe to another process, rather than directly to a file. This capability dramatically increases the flexibility of logging, without adding code to the main server.

In order to write logs to a pipe, simply replace the filename with the pipe character " ", followed by the name of the executable which should accept log entries on its standard input. The server will start the piped-log process when the server starts, and will restart it if it crashes while the server is running.

This last feature is why we can refer to this technique as "reliable piped logging". Piped log processes are spawned by the parent Apache httpd process, and inherit the userid of that process. This means that piped log programs usually run as root. It is therefore very important to keep the programs simple and secure. One important use of piped logs is to allow log rotation without having to restart the server. For example, to rotate the logs every 24 hours, you can use:. Notice that quotes are used to enclose the entire command that will be called for the pipe.

Although these examples are for the access log, the same technique can be used for the error log. As with conditional logging, piped logs are a very powerful tool, but they should not be used where a simpler solution like off-line post-processing is available. By default the piped log process is spawned without invoking a shell. This was the default behaviour for Apache 2. Depending on the shell specifics this might lead to an additional shell process for the lifetime of the logging pipe program and signal handling problems during restart.

For compatibility reasons with Apache 2. 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. 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. 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. This technique does not allow for easy collection of statistics on individual virtual hosts.

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. 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. Ask Question.

Asked 9 years, 5 months ago. Active 1 year, 6 months ago. Viewed k times. Improve this question. Gilles 'SO- stop being evil' k gold badges silver badges bronze badges. AkshaiShah AkshaiShah 3, 5 5 gold badges 16 16 silver badges 9 9 bronze badges. On what distribution, or with what hosting provider? Add a comment. Active Oldest Votes. Improve this answer. Gilles 'SO- stop being evil' Gilles 'SO- stop being evil' k gold badges silver badges bronze badges. Run sudo locate access.

Community Bot 1. Don Kirkby Don Kirkby 4 4 silver badges 4 4 bronze badges. If you found your access log file in another location, your error log file will be in the same location. Make sure you type the correct path. This can make it confusing to read, but each piece of information is displayed in a specific order. Just read across the line in your log file, and each entry can be decoded as above.

If there is no information, the log will display a hyphen. You can also create a custom log format by using the custom log module. For more information about decoding log formats, see this page. Apache log analysis gives you the opportunity to measure the ways that clients interact with your website. For example, you might look at a timestamp to figure out how many access requests arrive per hour to measure traffic patterns. You could look at the user agent to find out if particular users are logging in to a website to access a database or create content.

You could even track failed authentications to monitor various types of cybersecurity attacks against your system. The apache error log can be used similarly. A error happens when a client requests a missing resource, and this can alert you on broken links or other errors within the page.

However, it can also be used to find configuration glitches or even warnings about potential server problems.



0コメント

  • 1000 / 1000