Posts Tagged ‘Apache Log4PHP’

Apache Membership

Monday, August 2nd, 2010

When I was on vacation, something really wonderful happened to me. I have been invited to join the Apache Software Foundation as a member. This a huge honour for me – I would like to thank everybody who elected me. Of course I accepted this new role in no time. Now – my vacation is nearly over – I have to read some documents about this new role.  As a “shareholder”, as it is called, there are some more duties and of course benefits. Basically one has the chance to influence the organisation itself and help making it better. Let’s see how I can contribute in near future – it’s exciting, no question! :-)

Besides that, there is much on my to do list  for the next 12 months. The most urgent one currently is the Commons Compress 1.1 release, which should be started soon together with Stefan Bodewig. Of course log4php could benefit from a new release after so much contributions have been sent from users. And finally the log4j 2.0 discussions could be raised again, when all people are back from their holidays. Oh, and not to forget the promising Zeta Components – there is not to much to do for me at the moment, people there are really good and self organizing. But Zeta gives some good chances for Piwi, which has been planned to go to the ASF too. A framework based on Zeta and log4php might have good chances to succeed. You’ll see, my year will not get boring!

Welcome Zeta Components!

Wednesday, June 2nd, 2010

Before a while, there was a very promising Proposal called Zeta Components at the Apache Incubator list. It described a set of PHP components similar which eases the life of us all. It has already progressed very good before developers decided to switch to Apache. In the past days this library has been developed under the name eZ Components and was wellknown to the community.

In my opinion this new project will be very important to the ASF. Apache only hosts two other PHP projects, Log4PHP and Shindig. Since PHP is becoming more and more popular for big business (think on Facebook) I think its necessary to attract more developers and bring them into the Apache community. Many PHP projects out there use the GPL license, and that is sometimes very difficult to combine with commerical work. Good that we now have a component framework under ASL! Together with Log4PHP it’s a good start for much proprietary work.

More in future, I think that even the PIWI Framework will benefit of this change. I already had some trouble with dependent GPL code in it and hopefully Zeta can address most of my wishes. PIWI built upon Log4PHP and Zeta would be charming. But as already said, this will need a while.

At the moment, Zeta Components do already have a mailinglists and status page on the incubator. Jira will follow and after finally the CLAs of the initial developers have been processed, work can begin. However, if you are interest in helping this project subscribe to the user and to the dev list mentioned in the status page.

Lucky me I have been elected into the Apache Incubator PMC and can now serve as a mentor to this project. It’s not only honour to me, it’s also a good chance to work with obviously very nice people and excellent technicians. Also it makes it easy to me to step into this project and learn all I need.

So, welcome Zeta Components!! I am glad you arrived at the Apache Software Foundation!

Apache Log4PHP graduated!

Thursday, March 11th, 2010

Good news! The Apache Incubator Log4PHP project graduated as subproject to the Apache Logging project. This is really a big step forward! The next days I will try to push the real work behind a graduation forward, moving webpages and svn and such. After that move we’ll continue with a new small release. Cheers all!

Log4PHP tries to graduate to Apache Logging

Tuesday, March 2nd, 2010

The past year has been very well for Log4PHP. As you might have noticed, the Log4PHP 2.0.0 release is out. There has been some good feedback so far. Some users even contributed smaller bugfixes or the trace level which wasn’t in the API before. Besides that, there is a good activity on the mailinglist and there are at least 3 active committers. In other terms: time to graduate an bring out Log4PHP from the temporary incubator project :-)

Now Log4PHP needs to succeed 3 votes. One for the Log4PHP team to vote for graduating; one for Apache Logging to accept the podling as a subproject. And finally – after the first two have succeeded – a vote on the incubator list to release the podling to its final destination.

The first two votes are already running and it looks very good so far. Votes need to be open another day then the next step can be done. For those who are interested – there is a detailed document about graduation available.

Let’s see how it works out – I think everything could be in place in quite less time, maybe the next two or three weeks.

Apache Log4PHP 2.0.0 released

Monday, December 14th, 2009

After long work, I sent out the announcement for the first Log4PHP release this morning. Let’s see how this one works out – first reports from DBpedia users were promising. :-)

It’s an exciting time for all involved, and is the result of a culmination of many like-minded individuals. Everyone’s worked hard and as the initial test community seem to have responded positively and in such detail they could test anything from Word to Think Bingo (http://www.thinkbingo.com/) with their eyes closed. The people behind the development had a few words on the announcement of the first Log4PHP.

Here is the original statement:

The Log4PHP community is pleased to introduce the Apache Log4PHP 2.0.0 (Incubating) release [1]. It’s the first Log4PHP release since 2004 and tons of changes have been done. Finally Log4PHP has become a well tested framework made for PHP 5. Many thanks to all the contributors who made this release possible. Please download [2] Log4PHP and enjoy :-)

The Log4PHP team

[1] http://incubator.apache.org/log4php/changes-report.html
[2] http://incubator.apache.org/log4php/download.html

Performance of nonblocking writes to files via PHP

Friday, August 21st, 2009

This is not too easy. At Log4PHP we have exactly that problem right now. Somebody is using the FileAppender and figured out, that one Apache process was waiting looong time before it could write. Reason: the logger locked the Logfile for the whole time of the request. If you have lots of requests, you can think what it means. Performance is past, in the case.

Time for me to think about the different options to write to log files.

I figured out, that I have to compare the following options:

1) Not closing the file while the whole request is running. This is not an option in a live system, but will give me a good idea whats currently the case

$fp = fopen($file, 'a+');
while($count < $loop) {
   fwrite($fp, $text);
}
fclose($fp);

2) Closing the file directly after fwrite is called

while($count < $loop) {
   $fp = fopen($file, 'a+');
   fwrite($fp, $text);
   fclose($fp);
}

3) Use file_put_contents, which is known as an alias to fopen, fwrite and fclose

while($count < $loop) {
   file_put_contents($file, $text, FILE_APPEND);
}

4) Leave the file open while the whole request, but unlock it with flock and flock it again, when the next log event occurs

$fp = fopen($file, 'a+');
flock($fp, LOCK_UN);
while($count < $loop) {
   if (flock($fp, LOCK_EX)) {
      fwrite($fp, $text);
   }
   flock($fp, LOCK_UN);
}
fclose($fp);

5) Use a nonblocking stream for this and flock

$fp = fopen($file, 'a+');
stream_set_blocking($fp, 0);

while($count < $loop) {
   if (flock($fp, LOCK_EX)) {
       fwrite($fp, $text);
   }
   flock($fp, LOCK_UN);
}
fclose($fp);

6) Use the error_log method, which my friend Kevin Horst brought up

while($count < $loop) {
   error_log($text, 3, $file);
}

For each of this options I wrote a simple function which wrote 10000 times 100 characters in  a freshly created log file. I measured before opening and after closing. Additionally I tried out with 2 seperated threads if the write access is nonblocking. Good thing is, option 2 to 6 are actually nonblocking. And here are the timing results:

1) Execution with NOT closing the log file took 0.0668561458588 seconds
2) Execution with CLOSING the log after each write file took 30.1630220413 seconds
3) Execution with file_put_content took 30.153963089 seconds
4) Execution with leaving the file open, but LOCKING and UNLOCKING it took 0.148998975754 seconds
5) Execution with nonblocking stream took 0.149605989456 seconds
6) Execution with the error_log method took 30.069578886 seconds

Let’s see what it means.

Not closing the file until the 10000 fwrite calls are handled as actually the fastest. No surprise. It just took 0.0668 seconds but this one is not really an option, cause other threads have to wait until this request has been finished.

If you close the file after each fwrite and make it available to other threads and then reopen it, is hell. For 10000 calls of this kind I needed 30 seconds! It’s insane to have this in a productive system. The same goes with file_put_contents. Well, I allready knew (its in the php docs) that this method is nothing else then a wrapper for fopen, fwrite and fclose. Times are so similar that I say it’s exactly the same. Sometimes the one is some millis faster, sometimes the other.

If you open the file, unlock it with flock and flock it again it works very well. Just 0.14 ms for the 10000 fwrite calls. Thats the double amount of option 1, but yeah, here we do some more stuff. The interpreter cares about who is allowed to write, together with the OS. flock works that way, that a call to this function blocks until the requestor gets the actual lock. You can be sure that only one thread is actually writing.

Same goes to the nonblocking stream. This works with stream_set_blocking($fp, 0);. The file stream is nonblocking, means each thread could write at it the same time. That no mess happens, we need an flock here too. That brings us to the nearly same results as fopen, flock, fwrite, flock, fclose option above. But looking at the logfiles of this one and option 4, this one looks more nice to me. This is just subjective, but it looks like the lock is shared more nicely between both threads.

Last one is the error_log method. It didn’t had any idea what to expect, but… 30 seconds! This one behaviours like a wrapper for fopen, fwrite and fclose, like file_put_content. No guys, this is not really a method enabled for logging! If one would use this in a framework like Log4PHP, that would be hell to performance. I would think that this should better removed out. The name suggests a good logging method, but this is not the case.

Having that all said, Log4PHP will get the lock and unlock option number 4. I feel good with it, since it’s quite straightforward. I don’t have too much expierence with the non blocking stream and don’t want to have this in a framework like log4php is.

However, Logging must be used carefully at all. I thnk on a system with 10000 request a second. Enabling logging into one file could bring the system down. I think a live system should have the option to log exactly one request. Maybe triggered by an url param. Think carefully what you log and how you configure your live system.

The complete script can be found here.

Adobe Wave – Objectoriented API, first draft

Monday, August 3rd, 2009

For a while Adobe catched my attention with their new product Adobe Wave. It’s basically Growl, but for websites. Means one can subscribe and a website publisher can notify you if some update happens. I realized that I like AIR, the enviroment of the Wave client. Looking at the examples I put together a simple Wave script, which lets you publish news on your feed.

I think I will use a similar script for pushing stuff with Log4PHP. I will propose that today on the mailinglist. Additionally I think about making a WordPress plugin for my own blog. We’ll see how fast I am :-)

Your comments are appreciated!

Here is the wave script. Its released under Apache SL 2.0. Credits to the Wave team, I based everything on their examples. :-)

Committing to Log4PHP

Monday, April 27th, 2009

I just was off for a weekend to celebrate the wedding of good friends – and after returning I found myself beeing committer to Log4PHP. Well, OK, I wasn’t surprised since Gavin and I tried for over a month to get access to this repository. Finally we made it. :-)

Log4PHP is an api for logging within PHP applications. As the name suggests, it’s a port from Log4J which is todays standard in Java applications. Log4PHP has had several attempts to get running, but always went dry. It was february 2007 where lads kicked off the project again.

However, since I need this  Log4PHP as a dependency on PIWI I really don’t want to let it go. It has so much benefits to PIWI. And finally I don’t know a better logging tool than Log4J or its port Log4PHP is. Beside that Log4PHP is a great api, I think it will help to get PHP developers more attracted to Apache. This is important since there are so less PHP guys here. Apache Incubator Shindig is the only project I know with a regular contribution for PHP. Well, hopefully we get a community back the next days and hopefully some of those users turn into fullfledget committers too. We’ll see.

It’s some stuff todo. Nothing critical, just some design issues, small errors and some todos. I guess, we can work on a 1.0 once those issues are resolved. We’ll see :-)

Here are some links for further reading:

http://incubator.apache.org/log4php/

https://issues.apache.org/jira/browse/LOG4PHP

http://incubator.apache.org/projects/log4php.html

  • Categories

  • Recent Posts

  • Tags

  • Wave Notifications

    Download Adobe Wave now!

    This application requires Adobe® AIR™ to be installed for
    Mac OS or Windows.




Feeds