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 3284880
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:12:15+00:00 2026-05-17T20:12:15+00:00

So I recently discovered that the log4* package was available for PHP and upon

  • 0

So I recently discovered that the log4* package was available for PHP and upon seeing this eagerly downloaded the latest from the log4php website and followed the installation instructions. The instructions indicate that one is to download the tar package, untar, and place the following directory in a place of one’s choosing: log4php/src/main/php

Therefore I copied the contents of log4php/src/main/php into my lib dir under lib/log4php.

In my script, as required, I required the ‘Logger.php’ class and indicated a properties file to manage my appenders. The properties file, log4php.properties, is located on my filesystem at “/home1/ioforgec/www/devlab/pnotes/config/log4php.properties”.

Here is the logfile content:

#
# Example Logger
#
log4php.appender.EA1 = LoggerAppenderConsole
log4php.appender.EA1.target = STDOUT
log4php.appender.EA1.layout = LoggerLayoutPattern
log4php.appender.EA1.ConversionPattern = "%m"
log4php.appender.EA1.threshold = FATAL
log4php.exampleLogger = FATAL, EA1

So here is a copy of my script that implements (more or less ‘wraps’ the log4php functionality):

<?php

require_once('/home1/ioforgec/www/devlab/pnotes/lib/log4php/Logger.php');

class LogUtil
{
    public $logger;

    public $properties_file = "/home1/ioforgec/www/devlab/pnotes/config/log4php.properties";

    public static function logExample($msg)
    {
        Logger::configure($properties_file);
        $logger = Logger::getLogger("example");
        $logger->debug("Shouldnt see this print because of config max level FATAL");
        $logger->fatal($msg);
    }
}
?>

In order to test that this is working properly, the following script calls the LogUtil.php shown above:

#!/usr/bin/php
<?php
require_once("lib/utils/LogUtil.php");
LogUtil::logExample("example message");
?>

So, despite configuring the example logger to format the messages as the plain message, despite setting the level of the logger to a max of FATAL, not only in the logger declaration but also in the threshold command, the print to the console looks to me like the default root logger:

Mon Oct 18 20:30:05 2010,705 [827] DEBUG example - Shouldnt see this print because of config max level FATAL
Mon Oct 18 20:30:05 2010,711 [827] FATAL example - example message

I see the print statement without the plain formatting as specified, and I see two print statements, the debug print (which should never have printed due to the setting of FATAL on the logger config – FATAL is MUCH higher than DEBUG)

What on earth am I doing wrong? Ive tried every combination of setup I can possibly think of. Does anyone have any suggestions?

Edit – Update – This is still an issue. No progress.

Edit2 – Really? Has no one on this forum tried to use this very popular logging package and its incarnation as a PHP module?

I have tried every conceivable avenue to try and get my question answered, including the log4php user’s mailing list.

  • 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-17T20:12:16+00:00Added an answer on May 17, 2026 at 8:12 pm

    After many many more hours of manipulating the configuration file I have discovered a small, yet critically important factoid. In order to specify a ‘logger’ you must name it under the ‘logger’ hierarchy and its appenders under the ‘appender’ hierarchy, etc etc. For example:

    # for the 'console' logger named 'example' we first define the appender:
    log4php.appender.consoleAppender = LoggerAppenderConsole
    log4php.appender.consoleAppender.target = STDOUT
    log4php.appender.consoleAppender.layout = LoggerLayoutSimple
    
    # we then assign the appender and the minimum log level to the logger:
    log4php.logger.example = WARN, consoleAppender
    

    My mistake was in seeing the root logger hierarchy name ‘log4php.rootLogger’ and assuming that in order to assign a logger one need only name a value for ‘log4php.lognameLogger’. Sadly this is no excuse as there was an example, buried, in the documentation. I suppose finding it at 9+ hours is better than not at all 🙂

    Thanks to those who reminded me that there was more debugging work to be done, I appreciated the reminder to keep trying

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.