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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:18:14+00:00 2026-06-13T07:18:14+00:00

I have php file which contains class FooClass uses in a few projects. I

  • 0

I have php file which contains class “FooClass” uses in a few projects. I recently add method for logging with log4net like this:

private static function log($message,$level=0)
{
    if(!isset(self::$logger))
    {
        if(!class_exists("Logger")) return;
        self::$logger = Logger::getLogger("DBw");
        if(!isset(self::$logger)) return;
    }
    //logging
}

Some files that use FooClass can define the configuration by ising Logger::configure(“config.xml”).
But others don’t define it, and in that case the FooClass start to use LoggerConfiguratorDefault, which trace logs as “echo”. This is not acceptable.

I want to see if the configuration is not defined by other files, the FooClass did not log with LoggerConfiguratorDefault.

How can I do disable LoggerConfiguratorDefault or detect using of that and make return from function?

  • 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-06-13T07:18:15+00:00Added an answer on June 13, 2026 at 7:18 am

    I was in the same position, slightly different case: My configuration object does log if I access a value, but it cannot log if I access the config value for the configuration file of the logger.

    The class Loggerof log4php has a private static property $initialized, which is accessed through a private static method isInitialized(). I solved my problem by using Reflection to access the value of the static property, and if the result was false I returned a self-created NullLogger extends Logger that does nothing if any logging methods are called.

    Your class might be able to do the same, but the better solution will be to ensure log4php always is initialized.

    I’d suggest that you create a ticket in the projects Jira to have this issue resolved more easily. There really is no need to have the Logger::isInitialized() method private.

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

Sidebar

Related Questions

I have a php file that contains class which runs some lengthy database operations.
I have a php file which contains only one class. how can I know
I have a php file that contains a form (which contains 2 input boxes
I have a PHP file which will return something like <div id=title>Add Us On
I have downloaded php.vim file, which contains PHP-based syntax information. It should be able
i have a php file which stores a variable, and i need to create
I have a php file which checks for login and password from users database,
I have a php file which has some variables like $name1, $name2... How can
I have a PHP file which my clients will execute on their server. It
i have one php file which process adding of record in Database fro array.

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.