Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 582787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:43:27+00:00 2026-05-13T14:43:27+00:00

I want to create a custom Apache2 log handler, and the template that is

  • 0

I want to create a custom Apache2 log handler, and the template that is found on the apache site is:

#file:MyApache2/LogPerUser.pm
#---------------------------
package MyApache2::LogPerUser;

use strict;
use warnings;

use Apache2::RequestRec ();
use Apache2::Connection ();

use Fcntl qw(:flock);
use File::Spec::Functions qw(catfile);

use Apache2::Const -compile => qw(OK DECLINED);

sub handler {
  my $r = shift;

  my ($username) = $r->uri =~ m|^/~([^/]+)|;
  return Apache2::Const::DECLINED unless defined $username;

  my $entry = sprintf qq(%s [%s] "%s" %d %d\n),
      $r->connection->remote_ip, scalar(localtime),
      $r->uri, $r->status, $r->bytes_sent;

  my $log_path = catfile Apache2::ServerUtil::server_root,
      "logs", "$username.log";
  open my $fh, ">>$log_path" or die "can't open $log_path: $!";
  flock $fh, LOCK_EX;
  print $fh $entry;
  close $fh;

  return Apache2::Const::OK;
}
1;

What is the performance cost of the flocks? Is this logging process done in parallel, or in serial with the HTTP request? In parallel the performance would not matter as much, but I wouldn’t want the user to wait another split second to add something like this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:43:28+00:00Added an answer on May 13, 2026 at 2:43 pm

    Instead of worrying too much about what the costs might be, just try it and find out.

    First, benchmark your current configuration using ab or your favorite webserver torture tester. Many people forget this first step.

    Next, implement your change and try again. Compare the results.

    Some links that might help. They may be a little dated, but the basics are the same:

    • Howto: Performance Benchmarks a Webserver
    • Stress-Test Apache With ab

    Also remember, though, that you can do stuff after you’ve served the response. You don’t have to do everything while the client is waiting for a response. And, I wouldn’t sweat the flocks too much. If you don’t like them there are various other ways around it, including:

    • Writing to a different file per child and merging later
    • Sending a message to a single process that sequences the messages
    • Writing to a database (a more specific example of the single process idea)
    • Setting up a custom log format and letting apache handle it
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 526k
  • Answers 526k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer you can check the C:\Program Files\Inno Setup 5\Examples folder for… May 16, 2026 at 10:33 pm
  • Editorial Team
    Editorial Team added an answer You could set the outer div to position: relative then… May 16, 2026 at 10:33 pm
  • Editorial Team
    Editorial Team added an answer Use a transacted session. Consume the message and send the… May 16, 2026 at 10:33 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I want to create a custom page that has tournament brackets instead of the
I want to create a Custom Control derived from ComboBox , however if I
Background : I want to create a custom VB compiler, extending the original compiler,
I am working with the Silverlight RIA Services and I want to create custom
I want to create a custom malloc which allocates memory blocks within a given
I want to create a custom callout bubble on MKMapView. But I want to
I want to create two new custom buttons to use in my android application.
I want to add a custom property to a button in window form. Currently
Is there any possibility to create custom action in admin page for django UserModel?
I have a plesk panel and root dedicated server on 1and1. I'm using custom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.