Skip to content

Instantly share code, notes, and snippets.

@ihabunek
Created October 26, 2012 09:27
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ihabunek/3957832 to your computer and use it in GitHub Desktop.
Save ihabunek/3957832 to your computer and use it in GitHub Desktop.
Install Apache log4php using Composer

Install Apache log4php using Composer

First, install Composer if you don't yet have it:

php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"

Create a composer.json file with the following content:

{
    "require": {
        "apache/log4php": "2.3.0"
    }
}

Run the Composer install procedure:

php composer.phar install

This will install Apache log4php in vendor/apache/log4php.

To use log4php simply include vendor/autoload.php in your script.

require 'vendor/autoload.php';
$log = Logger::getLogger("foo");
$log->info("Yay! Works!");

Enjoy!

Links:

@jobrienski
Copy link

Thank you!

@cengiz-io
Copy link

Thanks! This helped me.

@i-amolo
Copy link

i-amolo commented Sep 17, 2017

Good day, does downloading the above dependencies require authentication ? because at some point during log4php installation using composer I am asked for username and password .

Kindly assist.

@vitman
Copy link

vitman commented Nov 21, 2018

if you are getting smth like this now (2018)

[RuntimeException]
Failed to execute git clone --no-checkout 'https://git-wip-us.apache.org/repos/asf/logging-log4php.git' '/var/www/123/vendor/apache/log4php' && cd '/var/www/123/vendor/apache/
log4php' && git remote add composer 'https://git-wip-us.apache.org/repos/asf/logging-log4php.git' && git fetch composer

this into composer.json:
"repositories": [
{
"type": "vcs",
"url": "git@github.com:apache/logging-log4php.git"
}
],

should help.

@mstyles
Copy link

mstyles commented Nov 21, 2018

apparently apache migrated where they were hosting it but forgot (didn't know about?) packagist: https://issues.apache.org/jira/browse/LOG4PHP-242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment