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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:39:18+00:00 2026-06-18T09:39:18+00:00

I have log4jConfig.xml as shown below <?xml version=1.0 encoding=UTF-8 ?> <!DOCTYPE log4j:configuration SYSTEM log4j.dtd>

  • 0

I have log4jConfig.xml as shown below

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" xmlns:log4j='http://jakarta.apache.org/log4j/'>

    <appender name="abcLog4j" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="/myapp/app/myserver/myproj/domains/logs/abcLog.log"/>
        <param name="Append" value="true"/>
        <param name="MaxFileSize" value="5000KB"/>
        <param name="MaxBackupIndex" value="5"/>
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
        </layout>
      </appender>

    <logger name="com.mywhole.mysub.abc" additivity="false">
         <level value="INFO"/>
         <appender-ref ref="abcLog4j"/>
    </logger>

    <appender name="xyzLog4j" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="/myapp/app/myserver/myproj/domains/logs/xyzLog.log"/>
        <param name="Append" value="true"/>
        <param name="MaxFileSize" value="5000KB"/>
        <param name="MaxBackupIndex" value="5"/>
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
        </layout>
      </appender>

    <logger name="com.mywhole.mysub.xyz" additivity="false">
         <level value="INFO"/>
         <appender-ref ref="xyzLog4j"/>
    </logger>

      <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">    
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
        </layout>   
     </appender>

    .......................

    <root>
        <priority value="ERROR"/>
        <appender-ref ref="sysoutLog4j"/>       
    </root>

   </log4j:configuration>

The probelm I’m facing is log statements generated from classes in com.mywhole.mysub.xyz are going into
abcLog.log and vice-versa. Can anyone explain me how to solve this issue

package com.mywhole.mysub.xyz.model;
// import ....
public class MyBeackingBean extends MySuperBB{
    public static final LoggerInterface log = LoggerFactory
            .getLogger(MyBeackingBean.class);
  • 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-18T09:39:19+00:00Added an answer on June 18, 2026 at 9:39 am

    The xml format of log4j should follow this pattern

    <!ELEMENT log4j:configuration (renderer*, appender*,(category|logger)*,root?, categoryFactory?)>   
    

    All the appenders should be declared before loggers

    So you log4j.xml should look like the following

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration debug="false" xmlns:log4j='http://jakarta.apache.org/log4j/'>
    
    <appender name="abcLog4j" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="/myapp/app/myserver/myproj/domains/logs/abcLog.log"/>
        <param name="Append" value="true"/>
        <param name="MaxFileSize" value="5000KB"/>
        <param name="MaxBackupIndex" value="5"/>
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
        </layout>
      </appender>
    
      <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">    
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
        </layout>   
     </appender>
    
    <appender name="xyzLog4j" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="/myapp/app/myserver/myproj/domains/logs/xyzLog.log"/>
        <param name="Append" value="true"/>
        <param name="MaxFileSize" value="5000KB"/>
        <param name="MaxBackupIndex" value="5"/>
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
        </layout>
      </appender>
    
    <logger name="com.mywhole.mysub.xyz" additivity="false">
         <level value="INFO"/>
         <appender-ref ref="xyzLog4j"/>
    </logger>
    
    <logger name="com.mywhole.mysub.abc" additivity="false">
         <level value="INFO"/>
         <appender-ref ref="abcLog4j"/>
    </logger>
    
    
    .......................
    
    <root>
        <priority value="ERROR"/>
        <appender-ref ref="sysoutLog4j"/>       
    </root>
    

    Check this link for more details here

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

Sidebar

Related Questions

Have a look at my AndroidMenifest.xml <?xml version=1.0 encoding=utf-8?> <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.myapp android:versionCode=1 android:versionName=1.0
Have some problem with Perl hashes. I have an XML: <?xml version=1.0 encoding=utf-8?> <SvnRequestUsers>
I have a spring application that has configured log4j (via xml) and that runs
I have a project using log4j. Now I have to introduce a library using
I have a Java web application that currently uses Log4J for logging. I'd like
Have an XML with next form: <categories someAttribute=test> <category id=1> <title></title> </category> <category id=1>
I have an application running on Jetty 8.0. I have configured the log4j to
This is my log4j configuration file, whenever I run the batch file to execute
I have a spring batch program where I am implementing skiplistener class as below:
have written this little class, which generates a UUID every time an object of

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.