Apache access logs, error logs, and Cronolog

Apache has two main logs at the vhost level, and those are the access_log and error_log. These two logs keep track of just what you might think–visitor information for each vhost, and any errors encountered, respectively. Though Apache has a lot of built-in customisation abilities regarding these logs (including the format of each, the log location, et cetera), it does not have much in the way of organising them. Before delving into the solution to that problem, let’s look at some of the customisation that can be done for each of these logs within Apache itself. For the access_log, one can choose what level of information is logged by setting up a LogFormat directive such as the one below:


LogFormat "%h %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined

What does this directive actually do? The first portion–LogFormat–is the Apache directive itself, and as such, instructs Apache that all of the options thereafter will be related to your desired formatting of its logs. Each element within the quotation marks instructs Apache to log certain elements, and here’s what each element listed above is:

  • %h – The host of the remote connection (the IP address of the visitor)
  • %u – The user that is trying to connect to a resource protected by HTTP Authentication (like Apache BasicAuth)
  • %t – The timestamp of the activity (in the default format of DD/MMM/YYYY:HH:MM:SS GMT+/- offset)
  • %r – The request line, which contains the method (i.e. GET / POST), the resource requested, and the protocol used
  • %>s – The HTTP status code that the user received for that resource (200 OK, 404 Not Found, et cetera)
  • %b – The size (in bytes) of the requested resource
  • %{Referer}i – The site from which the user came to request this resource
  • %{User-agent}i – Information about the user’s browser (e.g. Firefox, Chromium) and their OS (e.g. Windows 7, Linux, Android)

The last portion of the LogFormat directive is the nickname, which in this case is “combined.” That nickname can be referenced in conjunction with the CustomLog directive in each vhost in order to call the particular format. For instance, if I had a particular vhost for which I wanted this LogFormat, I would reference it with a line like:


CustomLog /var/www/domains/somedomain.com/host/logs/access_log combined

Where the first field (CustomLog) is the directive itself, the second field is the location of the log, and the third field is the nickname of the LogFormat that we previously defined.

One thing that Apache doesn’t have built in regarding logging, though, is organisation of the logs based on a time frame or similar. There is a programme that, even though it hasn’t been updated for some time now, works really well in achieving this goal. That programme is Cronolog. Many distributions might not have it in their repositories, and in those cases, one needs to compile it from source. However, Gentoo does offer it via Portage. Once you have it installed (either from your distribution’s package manager or compiled from source), configuring Cronolog is quite simple and straightforward. All that needs to be done is a slight change of syntax in the CustomLog directive from above. Here’s an example:


CustomLog "|/usr/sbin/cronolog /var/www/domains/somedomain.com/host/logs/%Y/%m/access_log" combined

Let’s break down that syntactical change piece by piece. The first field remains the same, as it is the Apache directive of CustomLog itself. The second field is now encased in quotation marks, and features the pipe to start. The pipe is essentially taking the logged information that Apache is gathering and passes it to the programme mentioned thereafter; namely, Cronolog (which is, by default, located at /usr/sbin/cronolog). Thereafter, the same log location is called, except for one key difference: the %Y and %m folders are now in the path. As you may have guessed, Cronolog creates a folder for the year (%Y), and subfolders for each month (%m) within it. When either of those stamps change (in this case, each month), new folders / subfolders are created, and Cronolog instructs Apache to log to the access_log file within the appropriate subfolder.

Pretty neat, and easy to set up eh? I hope that you feel empowered to use Cronolog within your Apache environment.

Cheers,
Zach

Interval running

As of late, I have started to enjoy my distance runs less and less. I’ve never really considering running to be one of my favourite exercises anyway (especially when compared to cycling and swimming), but now I’ve started to dread the idea of going for a run five or six days per week. Until today, I’ve always tried to gradually increase either my distance or my speed. For instance, over the course of the past 18 months, I progressed from barely being able to run 2km at 6 km/h to my current of between 13-16km at 13 km/h. My method of increasing speed and/or distance was continuous, meaning that I would run at the same pace for the duration of the run.

Over the past couple weeks, however, I’ve been doing a lot of reading and research regarding interval running. It is a training method where one runs at incredibly high intensity for a short burst, and then slows to a speed under his or her normal pace for the rest of the interval. There have been many studies attempting to provide empirical evidence (as well as many success stories providing anecdotal evidence) supporting the notion that interval running burns fat more quickly than does continuous running. Though one may burner fewer calories by interval training, the calories from fat may be utilised before calories from another source. Thus my rationale for trying this new method–I want to lower my body fat percentage. I believe that my weight (~68-70kg [~150-155 lbs] at any given time) is healthy for my height (177cm [~5’10”]), but that my body fat percentage (currently around 16.5%) is a little high. I’ve never been able to successfully keep my body fat percentage under 15.5% for any substantial length of time, and thought that maybe this type of training would help.

To better understand the concept of interval training, here’s how I went about my run today:

Time Pace Duration
0 – 5′ 7.5 km/h (~4.5 mph) 5′ warm-up
5′ – 6’30” 16 km/h (~10 mph) 1’30”
6’30” – 10′ 10.5 km/h (~6.5 mph) 3’30”
10′ – 11’30” 16 km/h (~10 mph) 1’30”
11’30” – 15′ 10.5 km/h (~6.5 mph) 3’30”
15′ – 16’30” 16 km/h (~10 mph) 1’30”
16’30” – 20′ 10.5 km/h (~6.5 mph) 3’30”
20′ – 21’30” 16 km/h (~10 mph) 1’30”
21’30” – 25′ 10.5 km/h (~6.5 mph) 3’30”
25′ – 26’30” 16 km/h (~10 mph) 1’30”
26’30” – 30′ 10.5 km/h (~6.5 mph) 3’30”
30′ – 31’30” 16 km/h (~10 mph) 1’30”
31’30” – 35′ 10.5 km/h (~6.5 mph) 3’30”
35′ – 36’30” 16 km/h (~10 mph) 1’30”
36’30” – 40′ 10.5 km/h (~6.5 mph) 3’30”
40′ – 41’30” 16 km/h (~10 mph) 1’30”
41’30” – 45′ 10.5 km/h (~6.5 mph) 3’30”
45′ – 46’30” 16 km/h (~10 mph) 1’30”
46’30” – 50′ 10.5 km/h (~6.5 mph) 3’30”
50′ – 51’30” 16 km/h (~10 mph) 1’30”
51’30” – 55′ 10.5 km/h (~6.5 mph) 3’30”
55′ – 56’30” 16 km/h (~10 mph) 1’30”
56’30” – 60′ 10.5 km/h (~6.5 mph) 3’30”
60′ – 65′ 4 km/h (~2.5 mph) 5′ cool-down

As you can see, my intervals were 5 minutes apiece with 90-second high-intensity bursts followed by 3.5 minute “rest” periods (which were not exactly restful, but were slower than my typical continuous training pace). I did a total of eleven intervals, which equates to 16’30” @ 16 km/h (~6.5 mph) and 38’30” @ 10.5 km/h (~6.5 mph). Combined with my 5-minute warm-up and 5-minute cool-down, that was 65 minutes of training. I’m interested in seeing how this type of training affects my body fat percentage over the upcoming weeks. Instead of doing interval training each day, I’m going to do 2 or 3 days of interval, and the remainder of days (totalling 5 per week) of continuous pace. I’ll certainly post my findings in a few weeks.

Cheers,
Zach

Kashi Banana Chocolate Chip Soft n’ Chewy Bar review

Having been a fan of many Kashi products over the years, and always enjoying a wonderful slice of homemade banana bread, I purchased the new Banana Chocolate Chip Soft n’ Chewy bars. Though the product doesn’t seem to get many positive reviews on the Kashi site or on other sites like Amazon, I thought that people just weren’t used to type of product that the brand often releases–a health-concious alternative to a typical treat.

Kashi Banana Chocolate Chip Soft n' Chewy Bar box

I tend to like to have such a snack a little bit before going to bed (I know, I know; there are probably better times to have a snack than right before bedtime, but that’s when I like something sweet). I was excited to try these seemingly tasty morsels for myself, so I poured a small glass of milk, and grabbed one of them out of the box. The first bite was interesting, as it didn’t really remind me of banana bread at all, but rather of something like the pumpkin spiced breads from Thanksgiving time. Looking at the ingredients list, that taste made more sense to me:

Kashi Banana Chocolate Chip Soft n' Chewy Bar nutrition

As you may notice, the first hint of something banana (banana purée) doesn’t show up until quite far down the list. In fact, “dried pumpkin” shows up before it! In any case, the bars are pretty good, all things considered, but I don’t know that I would describe them as Banana Chocolate Chip bars. Though they have those ingredients, it seems to me that Kashi is trying to say that they taste like banana bread. To me, they don’t really have a taste that I can readily compare to anything else; they have a unique flavour. The texture is somewhere in between a soft cookie and a cereal bar. Many reviewers said that they were dry, but I didn’t find them to be that bad. Actually, I think that they were significantly more moist than some of the other Kashi products that I’ve had in the past.

Though they aren’t the absolutely best tasting snack bars that I have ever had, I find them to be quite enjoyable, especially seeing as they only have 3g total fat (0.5 saturated) and 140 calories. I also like that they 4g of dietary fibre and have a half-serving of both fruits and vegetables. Overall, not a bad little snack, but I will disagree with Kashi’s suggestion that they are “kid friendly.” I don’t think that many kids would find them tasty.

Cheers,
Zach