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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:30:03+00:00 2026-05-25T10:30:03+00:00

We have a very simple log4j setup for tomcat. We have only a single

  • 0

We have a very simple log4j setup for tomcat. We have only a single log4j.properties file and have added the debug flag at startup to verify that the correct log4j.properties file is being used.

Here is our configuration:

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %.20t:%c{1}:%L - %m%n
log4j.appender.stdout2=org.apache.log4j.ConsoleAppender
log4j.appender.stdout2.Target=System.out
log4j.appender.stdout2.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout2.layout.ConversionPattern=%d{ABSOLUTE} %5p %.20t:%c{1}:%L - %m%n

log4j.rootLogger=INFO, stdout
log4j.logger.com.rei.framework.model.Table=INFO, stdout2
log4j.logger.com.rei.framework.view.SqlGridDisplayGroup=WARN, stdout2

The problem we are having is that unless I specifically list a logger for each class I get this error:

log4j:WARN No appenders could be found for logger (com.rei.util.DatabaseConnection).
log4j:WARN Please initialize the log4j system properly.

According to the docs the ROOT logger should be the default logger for any classes without a specific configuration line, yet I get many “No appenders found” warnings if I don’t enumerate each class in the configuration. With hundreds of classes in our project this is not maintainable.

We instantiate the logger this way inside each class:

static Logger logger = org.apache.log4j.Logger.getLogger(Myclass.class);

Any ideas why the root logger in this configuration is not being picked up for undefined classes?

  • 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-25T10:30:03+00:00Added an answer on May 25, 2026 at 10:30 am

    You are right, log4j.rootLogger should be the default configuration. The behaviour that you’re getting happens when you haven’t got the line

    log4j.rootLogger=INFO, stdout
    

    in your file. I’ve tested with the above file, and this works for me. Therefore, in the file you’re actually using, you don’t have that line, or you’re using a different version of log4j from me (I’ve tried with 1.2.9 to 1.2.16).

    When you specify the -Dlog4j.debug on the command line, you should get output like:

    log4j: Using URL [file:/C:/developpement/mjf-workspace/Stackoverflow/lib/log4j.properties] for automatic log4j configuration.
    log4j: Reading configuration from URL file:/C:/developpement/mjf-workspace/Stackoverflow/lib/log4j.properties
    log4j: Could not find root logger information. Is this OK?
    log4j: Parsing for [com.rei.framework.model.Table] with value=[INFO, stdout2].
    log4j: Level token is [INFO].
    log4j: Category com.rei.framework.model.Table set to INFO
    

    Do you get the line:

    log4j: Could not find root logger information. Is this OK?
    

    If you are getting that, then there is something wrong with your log4j.properties file. This is the java class I’m using to test:

    package uk.co.farwell.stackoverflow;
    
    import org.apache.log4j.*;
    
    public class Log4jTest {
        static Logger logger = Logger.getLogger(Log4jTest.class);
    
        public static void main(String args[]) {
            logger.debug("hello Log4jTest");
        }
    }
    

    EDIT: It turns out that the Logger class that you’re importing into the class and thus using is the Apache commons logging, not log4j. Apache commons logging uses rootCategory, not rootLogger (see Configuring Log4J:

    log4j.rootCategory=INFO, stdout
    

    This is why it’s not picking up the default logger. Try adding this line to your log4j.properties.

    It’s not a good idea to mix your logging frameworks, so pick one and stick with it. If commons logging works for you, use that. But don’t mix and match in your code. It’s a bad idea, and leads to a lot of confusion.

    Personally, I always use slf4j. slf4j allows you to have one single configuration for multiple frameworks, so I use that by default. slf4j is often mandatory, because third party libraries use commons logging or even java logging, and you can’t change this. slf4j uses a bridge so that everything turns up in the same place, and works too.

    It also has a number of advtanges, such as parameterized logging.

    Recommendation: use slf4j.

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

Sidebar

Related Questions

I have very simple persistance.xml file: <?xml version=1.0 encoding=UTF-8?> <persistence version=1.0 xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/persistence
I have a very simple class that opens a file and creates a memory
i have a very simple excel file that i need to import into a
i have very simple problem. I need to create model, that represent element of
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have a very simple problem which requires a very quick and simple solution
I have a very simple WPF application in which I am using data binding
I have a very simple bit of script that changes the status of an
I have a very simple TCP server written in C. It runs indefinitely, waiting
I have a very simple Java RMI Server that looks like the following: import

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.