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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:48:43+00:00 2026-05-28T14:48:43+00:00

My log4j.xml : <appender name=B2BAPP class=org.apache.log4j.RollingFileAppender> <param name=File value=/LOGS/SAM/B2B_VJ.log/> <param name=Threshold value=ERROR/> <param name=MaxFileSize

  • 0

My log4j.xml:

 <appender name="B2BAPP" class="org.apache.log4j.RollingFileAppender">
     <param name="File" value="/LOGS/SAM/B2B_VJ.log"/>   
     <param name="Threshold" value="ERROR"/> 
     <param name="MaxFileSize" value="10000KB"/>
     <param name="MaxBackupIndex" value="10"/>
     <param name="Append" value="false"/>
     <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss,SSS} %5p [%c:%L] %m%n"/>
     </layout>      
</appender>

<logger name="com.sas">    
   <priority value="DEBUG"/>
   <appender-ref ref="B2BAPP"/>
</logger>

I would like to understand the behaviour of priority value=”DEBUG” and param name=”Threshold” value=”DEBUG”.

In my logger (com.sas) I have set the priority value “DEBUG” and appender of this logger is “B2BAPP” and in “B2BAPP” I have defined “Threshold” as “ERROR”.

So log level for “com.sas” would be set to “DEBUG” or “ERROR”?

Cases :

priority value=”DEBUG” and param name=”Threshold” value=”ERROR”

priority value=”ERROR” and param name=”Threshold” value=”DEBUG”

What would be the output of the above cases? How does it work?

  • 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-28T14:48:44+00:00Added an answer on May 28, 2026 at 2:48 pm

    The Logger component accepts logging instructions (logger.debug(), logger.error() etc calls) and sends them to appropriate destinations to the Appenders.

    You can set a “priority” on the Logger and instruct it to accept only logging instructions of a certain level. The levels are (in ascending importance order): TRACE, DEBUG, INFO, WARN, ERROR and FATAL.

    A configuration like this:

    <logger name="com.sas">
        <priority value="WARN" />
        ....
    </logger>
    

    instructs the com.sas logger to only accept levels with a level of importance of WARN or higher (i.e. WARN, ERROR and FATAL).

    The logging statements are then sent to Appenders. The appenders can also be configured to accept only statements of a certain importance level, one above a certain “threshold”.

    A configuration like:

    <appender name="B2BAPP" class="org.apache.log4j.RollingFileAppender">
       <param name="Threshold" value="ERROR"/> 
       ....
    </appender>
    

    tells the appender to only accept statements of ERROR importance or above (i.e. ERROR and FATAL).

    So log level for “com.sas” would be set to “DEBUG” or “ERROR”?

    In your example the log level is set to DEBUG. What gets written by the appenders is orthogonal to the issue.

    As for your two examples:

    priority value=”DEBUG” and param name=”Threshold” value=”ERROR”

    priority value=”ERROR” and param name=”Threshold” value=”DEBUG”

    1. Logger priority set to DEBUG and appender threshold set to ERROR means that the logger passes along DEBUG, INFO, WARN, ERROR and FATAL but appender only accepts ERROR and FATAL so you get only ERROR and FATAL into your log.

    2. Logger priority set to ERROR and appender threshold set to DEBUG means that the logger passes along only ERROR and FATAL while the appender accepts DEBUG, INFO, WARN, ERROR and FATAL. You again get only ERROR and FATAL into your log.

    But that’s just an unfortunate case. Mixing the priority and the threshold can get you some nice functionality. For example…

    … assume you just placed an application in staging and you need to monitor it for a bit until you move it to production. You have a developer and a system administrator doing the monitoring. While the developer want all the logs, the system administrator is busy and only wants to see the errors.

    How do you configure that? How about something like this:

    <appender name="developerLogs" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="/LOGS/SAM/developerLogs.log" />
        <param name="Threshold" value="DEBUG" />
        <param name="Append" value="false" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%m%n"/>
        </layout>
    </appender>
    
    <appender name="sysAdminLogs" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="/LOGS/SAM/sysAdminLogs.log" />
        <param name="Threshold" value="ERROR" />
        <param name="Append" value="false" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%m%n"/>
        </layout>
    </appender>
    
    <logger name="com.test">
        <priority value="DEBUG" />
        <appender-ref ref="developerLogs" />
        <appender-ref ref="sysAdminLogs" />
    </logger>
    

    If you run code like:

    Logger logger = Logger.getLogger("com.test");
    
    logger.debug("some debug statement");
    logger.info("some info statement");
    logger.warn("some warn statement");
    logger.error("some error statement");
    logger.fatal("some fatal statement");
    

    you get this in sysAdminLogs.log:

    some error statement
    some fatal statement
    

    and this in developerLogs.log:

    some debug statement
    some info statement
    some warn statement
    some error statement
    some fatal statement
    

    Hope this explanation better describes the concepts.

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

Sidebar

Related Questions

I have the following log4j.xml configuration: <log4j:configuration> <appender name = CONSOLE class = org.apache.log4j.ConsoleAppender>
I am adding loggers at runtime in log4j.xml <logger name=com.bas> <priority value=DEBUG/> <appender-ref ref=B2BAPP/>
I am trying to run a jar with the log4j.xml file on the file
I am currently watching an XML file from log4j output. I have a custom
I have a custom java log4j appender class like com.xyz.abc.MyCustomAppender. I am able to
I'm trying to use log4j my log4j.propreties: log4j.rootLogger=DEBUG, out log4j.logger.org.springframework=INFO log4j.logger.org.apache.activemq=INFO log4j.logger.org.apache.activemq.spring=WARN log4j.logger.org.apache.servicemix=DEBUG, stdout
I have implement a log4j.xml file having two loggers. Both EventLogger and ErrorLogger logged
I can't configure org.hibernate.type (logging bind variables used in hibernate prepared statements) using log4j.xml,
I want to read log4j.xml file which is outside the jar inside etc folder.
With current log4j.xml shown below, I get logs like 'select * from users where

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.