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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:29:47+00:00 2026-05-18T00:29:47+00:00

I am using Log4j in my application, and the libraries that I use that

  • 0

I am using Log4j in my application, and the libraries that I use that also use Log4j are also outputting their logs to the log files that I create. I have already created appenders to redirect the logs of one library to an “other.log” file, but the other libraries keep logging to my main “info.log” file.

This is my log4j.properties. Notice that in the end, I create a category for the library alibrary.apackage and a category for myproject.apackage, so that the library logs go to one appender and the project logs go to another appender.

log4j.rootLogger=ALL,InfoAppender,OtherAppender

# AdminFileAppender - used to log messages in the admin.log file.
log4j.appender.InfoAppender=org.apache.log4j.FileAppender
log4j.appender.InfoAppender.File=info.log
log4j.appender.InfoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoAppender.layout.ConversionPattern= %d{yyyy/MM/dd HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n
log4j.appender.InfoAppender.Threshold=DEBUG

log4j.appender.OtherAppender=org.apache.log4j.FileAppender
log4j.appender.OtherAppender.File=other.log
log4j.appender.OtherAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.OtherAppender.layout.ConversionPattern= %d{yyyy/MM/dd HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n
log4j.appender.OtherAppender.Threshold=ALL

log4j.category.alibrary.apackage=DEBUG,OtherAppender
log4j.additivity.com.mchange.v2=false
log4j.category.myproject.apackage=ALL,InfoAppender
log4j.additivity.trackme=false

I still keep getting the following though:

In the “info.log”:

...Logs that I want to be here...
Logs that I do not want to be here, that should go to "other.log". Ex.:
2010/10/28 15:29:25,667 [main] DEBUG org.apache.jasper.compiler.JspRuntimeContext  - Parent class loader is: ContextLoader@null
2010/10/28 15:29:25,668 [main] DEBUG org.apache.jasper.servlet.JspServlet  - ...
2010/10/28 15:29:25,668 [main] DEBUG org.apache.jasper.servlet.JspServlet  - IMPORTANT: Do not modify the generated servlets

In the “other.log”:

All the logs that I do not want in "info.log" are here. OK.

My question is: How do I redirect all the unwanted logs – that is, logs from other libraries – to the “other.log”?

  • 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-18T00:29:48+00:00Added an answer on May 18, 2026 at 12:29 am

    You want to make OtherAppender the rootLogger and specifically push the messages you want into InfoAppender.

    I’d leave the appender definitions the same and then configure the loggers like this:

    log4j.rootLogger=ALL,OtherAppender
    log4j.category.alibrary.apackage=DEBUG # will default to OtherAppender
    log4j.additivity.com.mchange.v2=false
    log4j.category.myproject.apackage=ALL,InfoAppender # will go to both logs
    log4j.additivity.trackme=false
    

    That will route everything into OtherAppender and just things from myproject.apackage into InfoAppender.

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

Sidebar

Related Questions

I have a web application that dumps logging information in a file using log4j
So we have our J2EE application using Log4j like this public class CustomerController {
A web application running in Websphere is using log4j SysLogAppender to log messages to
I'm using log4j to log in application. Now the log file is created in
My application has a homebrew logging class that I'm migrating to using log4j under
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I have an existing application which does all of its logging against log4j. We
I am using Log4J in my application for logging. Previously I was using debug
I am using Java 1.4 with Log4J. Some of my code involves serializing and
Using online interfaces to a version control system is a nice way to have

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.