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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:49:08+00:00 2026-06-04T08:49:08+00:00

I want to have two log files in my application (Spring Integration), debug.log and

  • 0

I want to have two log files in my application (Spring Integration), debug.log and main.log. I want to run main.log at an INFO level and debug.log at a DEBUG level. This is doable with filters on the appenders. I want to log different levels to the appenders based on the source. In other words

<logger name="org.springframework" level="ERROR">
    <appender-ref ref="main" />
</logger>
<logger name="org.springframework" level="DEBUG">
    <appender-ref ref="debug" />
</logger>
<logger name="com.myapp" level="INFO">
    <appender-ref ref="main" />
</logger>
<logger name="com.myapp" level="DEBUG">
    <appender-ref ref="debug" />
</logger>

So to summarise:

  1. Spring logger
    • main -> ERROR
    • debug -> DEBUG
  2. com.myapp logger
    • main -> INFO
    • debug -> DEBUG

Because of this I have to have the loggers running at DEBUG and a threshold filter on an appender isn’t fine grained enough.

Update Added clarity to the question

  • 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-04T08:49:10+00:00Added an answer on June 4, 2026 at 8:49 am

    Create a ThresholdLoggerFilter class which can be put on an appender like:

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <filter class="com.myapp.ThresholdLoggerFilter">
            <logger>org.springframework</logger>
            <level>ERROR</level>
        </filter>
    </appender>
    

    The following code works

    package com.myapp;
    
    import ch.qos.logback.classic.Level;
    import ch.qos.logback.classic.spi.ILoggingEvent;
    import ch.qos.logback.core.filter.Filter;
    import ch.qos.logback.core.spi.FilterReply;
    
    public class ThresholdLoggerFilter extends Filter<ILoggingEvent> {
        private Level level;
        private String logger;
    
        @Override
        public FilterReply decide(ILoggingEvent event) {
            if (!isStarted()) {
                return FilterReply.NEUTRAL;
            }
    
            if (!event.getLoggerName().startsWith(logger))
                return FilterReply.NEUTRAL;
    
            if (event.getLevel().isGreaterOrEqual(level)) {
                return FilterReply.NEUTRAL;
            } else {
                return FilterReply.DENY;
            }
        }
    
        public void setLevel(Level level) {
            this.level = level;
        }
    
        public void setLogger(String logger) {
            this.logger = logger;
        }
    
        public void start() {
            if (this.level != null && this.logger != null) {
                super.start();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two files, CUSTOMER_ACCOUNT_LOG.TXT, CUSOMER_ID_LOG.TXT. Am this is log, maintain the timestamp and
I want to have two EntityManagerFactories ( org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in this case), with each of
I have a question regarding logging in a Java application. I want to log
I have a pure virtual class for storing log data. This class has two
I have two forms on one page and want to have the input boxes
I want to have two radio buttons in my Asp.Net MVC3 App.There is no
I want to have two buttons top of a listview. If I scroll below
I want to have two items on the same line using float: left for
I want to have two Emacs windows on the screen: one for Dired and
Hi I want to have two tables each have an INT id column which

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.