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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:01:15+00:00 2026-05-30T17:01:15+00:00

I am trying to create 2 log files using log4j using this configuration: log4j.rootLogger=debug,stdout,logfile

  • 0

I am trying to create 2 log files using log4j using this configuration:

log4j.rootLogger=debug,stdout,logfile
#debug info warn error fatal 

# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache=FATAL,logfile

# ConsoleAppender properties
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.Threshold=debug
log4j.appender.stdout.layout.ConversionPattern=%d %5p %c{1}:%L - %m%n
#%-5p [%t]: %m%n

# LogFileAppender properties
log4j.appender.logfile=com.xx.util.SizeRollingFileAppender
log4j.appender.logfile.File=log.log
log4j.appender.logfile.MaxFileSize=50240KB
log4j.appender.logfile.BackupsDirectory=log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %5p %c{1}:%L - %m%n
log4j.appedner.logfile.Threshold=error


# Log1FileAppender properties
log4j.appender.log1=com.xx.util.SizeRollingFileAppender
log4j.appender.log1.File=log1.log
log4j.appender.log1.MaxFileSize=5120KB
log4j.appender.log1.BackupsDirectory=log
log4j.appender.log1.layout=org.apache.log4j.PatternLayout
log4j.appender.log1.layout.ConversionPattern=%d %5p %c{1} :%L - %m%n

(the xx is for the project that I am working on) –

And here it is the Java Code:

public class TestLog4j {

/**
 * @param args
 */
private static org.apache.log4j.Logger log              = org.apache.log4j.Logger.getLogger(TestLog4j.class);
private static org.apache.log4j.Logger log1= org.apache.log4j.Logger.getLogger("log1");

public static void main(String[] args) {

    // TODO Auto-generated method stub
    org.apache.log4j.PropertyConfigurator.configure("src/com/test/log4j.properties");
    log.error("Error Test Log");
    log1.info("Test Log1");
}

}

My problem is that I want to write two different files, one for log and one for log1. What I am getting with this code is only one file being created with both logs in the same file.

What I am doing wrong?

  • 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-30T17:01:17+00:00Added an answer on May 30, 2026 at 5:01 pm

    Short answer:

    Add:

    log4j.logger.log1=<yourLogLevel>,log1
    

    to your log4j.properties.

    NOTE:

    Every enabled log-request to log1 (log-level >= yourLogLevel) will go to both stdout and logfile unless you turn off appender-additivity!

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

Sidebar

Related Questions

I'm trying to perform some super simple parsing o log files, so I'm using
I'm lost here. I create files using this (stripped) code : File dir =
I'm trying to create a new log file every hour with the following code
I am trying to create a simple log in system that uses ajax but
I am trying to create a rule for snort to basically log any packets
In a view I'm trying to create a new user and then log them
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Ok so I am trying create a login script, here I am using PHP5
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
I'm trying out log4j in a simple test app. I create a new Java

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.