apache2 error log massive

battletoad

Expert Member
Joined
Mar 10, 2009
Messages
1,461
Reaction score
52
This should probably be in the soft&web section, but I feel its more of a linux issue.

Setup:
1. apache 2.2.22 mysql 5.5 php in a VM on ubuntu server 12.04
2. VM housed in a different department as a demonstration of a website I'm selling them.
3. ssh access only through keys.
4. /var/www mounted as sshfs to a server I trust for the dev (same server with key).

/var/log/apache2/error.log becomes massive very quickly. Deleted a 6.8GB file this afternoon, now it's ballooning to about 600MB after a few hours.

Googled a lot, but all the results refer to files which I cannot find. Made a few webservers in the past but haven't come across this problem yet.

Any way to either:
1. set a limit on the log file?
2. stop it altogether?
 
This should probably be in the soft&web section, but I feel its more of a linux issue.

Setup:
1. apache 2.2.22 mysql 5.5 php in a VM on ubuntu server 12.04
2. VM housed in a different department as a demonstration of a website I'm selling them.
3. ssh access only through keys.
4. /var/www mounted as sshfs to a server I trust for the dev (same server with key).

/var/log/apache2/error.log becomes massive very quickly. Deleted a 6.8GB file this afternoon, now it's ballooning to about 600MB after a few hours.

Googled a lot, but all the results refer to files which I cannot find. Made a few webservers in the past but haven't come across this problem yet.

Any way to either:
1. set a limit on the log file?
2. stop it altogether?



What's generating all the log data? If its PHP error_logging a lot of things it should not be for production or at least wrapped to disable it with a single $debugmode = false; flag. Otherwise use logrotate to automatically zip and rename file at x Mb ... Lastly - I would not recommend - set the apache log path to: /dev/null In. /etc/apache2/httpd.conf But then you don't have a log... Which is your last line of audit if things go wrong...
 
What type of messages do you get?

It should be save to just disable the errorlog, and then only enable if you have problems.
 
I would not disable the error log, as you will probably have valid errors in there (either Apache config issues or application issues). I would analyse the log file first, it should never get that big and then also implement log-rotation to rotate the log-files out.
 
If you error log is so huge there is definitely an unresolved error :D

Fix the error, fix the error log issue.

My error logs are quite small:

Code:
-rw-r--r--   1 root root  36K Jul 17 10:45 error_log
-rw-r--r--   1 root root  29K Jun 23 03:47 error_log-20130623
-rw-r--r--   1 root root  25K Jun 30 03:59 error_log-20130630
-rw-r--r--   1 root root  15K Jul  7 03:30 error_log-20130707
-rw-r--r--   1 root root  28K Jul 14 03:48 error_log-20130714
 
thanks guys

Well, analysed the file a bit. At one point it noted that a session variable didn't exist, so that was cool. 99.9% of the time however it simply logs every last thing that happens, i.e. user connected from this ip, accessed that file, etc. Weird, since its not an error. Overkill for logging to be honest.

Deleted the 600MB file lastnight, and it hasn't come back yet (it should since I deleted the 6GB file yesterday in the afternoon). I will have a look at this logrotate solution.

I wouldn't want to disable logging, I'd love to have Zoidberg's setup though! :D

Will go through each function of the site to generate a new error log and post here for critique.

Aside: access.log. http headers for each connection. And a wrote a damn script that did that for me, saved to database, provided statistics, etc. ... when I should just have looked at access.log *facepalm*
oh well I can always reuse that script and apply it to access.log
 
At one point it noted that a session variable didn't exist, so that was cool.

That's a very amateurish error. You should have a stern talk to your developer.

99.9% of the time however it simply logs every last thing that happens, i.e. user connected from this ip, accessed that file, etc.

That sounds like your application is logging activities, not Apache or PHP.
 
Are the access log and error log being dumped into the same place?
Its also probably a case of the log verbosity being at a debug level rather than a production level.
 
Also get the dev to do custom logging for the application to another log file to see if the application is doing the logging.
 
I would start here http://httpd.apache.org/docs/2.4/logs.html. Looks like it's a custom Apache installation and I would go and compare your httpd.conf with the default one. You can split access and error logs and also reduce the level of detail being logged. Your error log should be super small (unless you have many 404s).
 
dont run logs so that you dont have to give the government agencies ****
 
That's a very amateurish error. You should have a stern talk to your developer.



That sounds like your application is logging activities, not Apache or PHP.

I'm the dev :eeek: it's still being put together and I'm moving files around/changing code.

Stress tested every feature of the fledgling site, no error logs yet. Not a single byte. Everything is quiet now.

But here's more info concerning the application (it's really simple though):
1. User can search database. With javascript, results are returned in realtime and populates a table. If on intranet, returns instantly. If outside, waits 2 secs after last keypress before returning. Now fine, I suppose plenty of data can be generated, but 600MB after a few hours for errors? And I'm the only one using the site?!?!

2. User can upload csv file, file is read and data is inserted into database. I've built a dictionary to cover similar terms different to those of the column names and proceed accordingly, but everything slots in nicely. I really see no reason for errors.

will have a look at apache2.4. thanks again
 
I'm the dev :eeek:

OK. Take a tip from a system administrator. Every time your application generates an error, your server is wasting cycles. Every time apache logs that error, you're wasing hard disc I/O cycles. And take note: disabling logging does not mean errors are not generated. They're just not logged.

So, while you're developing, enable all the logging you can. Then, ssh into your server, and type the following:

Code:
tail -f /path/to/error_log

Watch that log and attend to errors right away.

Now fine, I suppose plenty of data can be generated, but 600MB after a few hours for errors? And I'm the only one using the site?!?!

Well, what do the errors say? 600MB of errors is not unusual. They're there to tell you something.
 
OK. Take a tip from a system administrator. Every time your application generates an error, your server is wasting cycles. Every time apache logs that error, you're wasing hard disc I/O cycles. And take note: disabling logging does not mean errors are not generated. They're just not logged.
will keep this in mind
Well, what do the errors say? 600MB of errors is not unusual. They're there to tell you something.
No errors today. Will force a few errors tomorrow just to check if the logging still works (pretty sure it does).

contents of apache2.conf relevant to logging is standard, I have not touched anything:
Code:
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

# Include module configuration:
Include mods-enabled/*.load
Include mods-enabled/*.conf

# Include all the user configurations:
Include httpd.conf

# Include ports listing
Include ports.conf

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
Include conf.d/

# Include the virtual host configurations:
Include sites-enabled/
 
You are not looking at the right things - you should look at LogLevel and CustomLog (the variable after the file-name is really what is used to be logged)

PHP:
#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
ErrorLog logs/error.log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

#
# For a single logfile with access, agent, and referer information
# (Combined Logfile Format), use the following directive:
#
CustomLog logs/access.log combined
 
You are not looking at the right things - you should look at LogLevel and CustomLog (the variable after the file-name is really what is used to be logged)

PHP:
#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
ErrorLog logs/error.log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

#
# For a single logfile with access, agent, and referer information
# (Combined Logfile Format), use the following directive:
#
CustomLog logs/access.log combined

My apache2.conf says
Code:
ErrorLog ${APACHE_LOG_DIR}/error.log 
#from envvars found in apache2 dir
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
My LogLevel is set to "warn".

There is no CustomLog definition in my apache.conf (my previous post for reference, still the exact same config).

I'm not sure which other files I need to post for you to make sense of my setup.

Perhaps the undefined php session variables I removed fixed everything? Maybe they had a knock on effect... off to debugging with me!
 
Top
Sign up to the MyBroadband newsletter
X