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

  • Home
  • SEARCH
  • 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 7711913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:29:48+00:00 2026-06-01T01:29:48+00:00

I have the following log4j.properties file: log4j.rootLogger=DEBUG,A1,A2,A3 log4j.appender.A1=org.apache.log4j.RollingFileAppender log4j.appender.A1.Threshold=DEBUG log4j.appender.A1.File=log.out log4j.appender.A1.MaxFileSize=100KB log4j.appender.A1.MaxBackupIndex=1 log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%p

  • 0

I have the following log4j.properties file:

log4j.rootLogger=DEBUG,A1,A2,A3

log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.Threshold=DEBUG
log4j.appender.A1.File=log.out
log4j.appender.A1.MaxFileSize=100KB
log4j.appender.A1.MaxBackupIndex=1
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%p %d %t %c - %m%n

log4j.appender.A2=org.apache.log4j.RollingFileAppender
log4j.appender.A2.Threshold=WARN
log4j.appender.A2.File=warnings.out
log4j.appender.A2.MaxFileSize=100KB
log4j.appender.A2.MaxBackupIndex=1
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%p %d %t %c - %m%n

log4j.appender.A3=org.apache.log4j.RollingFileAppender
log4j.appender.A3.Threshold=ERROR
log4j.appender.A3.File=errors.out
log4j.appender.A3.MaxFileSize=100KB
log4j.appender.A3.MaxBackupIndex=1
log4j.appender.A3.layout=org.apache.log4j.PatternLayout
log4j.appender.A3.layout.ConversionPattern=%p %d %t %c - %m%n

In my Java program, I have the following variable defined:

private Logger logger = Logger.getRootLogger();

static {
    URL url = MyClass.class.getClassLoader().getResource("/log4j.properties");

    if (url == null) {
        // log4j.properties not found in CLASSPATH, revert to console output
        BasicConfigurator.configure();
    }
    else {
        // log4j.properties found
        PropertyConfigurator.configure(url);
    }
}

Why is it when I call the logger methods, the output also goes to the console (stdout), in addition to the 3 output files?

  • 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-01T01:29:50+00:00Added an answer on June 1, 2026 at 1:29 am

    If you are going to name your file log4j.properties and put it in the root of your classpath, then it will be picked up by default, you don’t need to pass it to BasicConfigurator.

    What is probably happening in your case is that Java’s classloader is not finding the file there (on the root), your call to BasicConfigurator.configure() without parameters is getting log4j to use the default configuration.

    Make sure log4j.properties is a the root of your war file’s classpath, i.e.:

    WEB-INF\classes\log4j.properties

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

Sidebar

Related Questions

I have following information in log4j.properties file.. log4j.appender.file = org.apache.log4j.DailyRollingFileAppender log4j.appender.file.File = C:\\app\\file.log log4j.appender.file.Threshold
I have the following on my log4j.properties log4j.rootLogger = debug, stdout, fileLog log4j.appender.stdout =
I have the following in my log4j file #set httpclient debug levels log4j.logger.org.apache.component=ERROR,stdout log4j.logger.httpclient.wire=ERROR,stdout
I have the following log4j.xml configuration: <log4j:configuration> <appender name = CONSOLE class = org.apache.log4j.ConsoleAppender>
I have the following: package test.tester; import org.apache.log4j.Logger; public class tester { private static
I have configured a project with Log4j. I have configured log4j using log4.properties file.
I have to deploy a web app and the the log4j.properties file is created
I have a log4j.properties file as part of my application. #Updated at Thu Apr
I have the following in log4j.xml file, when I run my application. Only error
I have the following code: import org.apache.commons.lang.exception.ExceptionUtils; public void myMethod() { try { //

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.