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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:00:49+00:00 2026-05-12T14:00:49+00:00

I would like to filter log events coming from a specific component of a

  • 0

I would like to filter log events coming from a specific component of a 3rd party library, based on the content of the log message. I only want this filtering to be applied when the log event is generated by a specific logger: “org.restlet.Component.LogService”. The filtering itself is just a basic match against the log event message.

I have a central AsyncAppender that logs to multiple appenders. In the case that events coming from LogService are not filtered out, I’d like them to be treated the same as they are now — that is, get sent to the AsyncAppender. I don’t want to add a filter to the AsyncAppender, because this seems terribly inefficient (I don’t need to filter ALL events, just the ones coming from the LogService logger).

So what I’ve tried to do is associate LogService logger with a custom Appender, which in turn is associated with a custom Filter:

    <appender name="filtered" class="mystuff.FilteredAppender">
            <filter class="mystuff.EventFilter"/>
            <appender-ref ref="ASYNC"/>
    </appender>

    <logger name="org.restlet.Component.LogService">
            <appender-ref ref="filtered"/>
    </logger>

The error I currently get…

log4j:ERROR No layout set for the appender named [filtered].

…tells me there’s something wrong with my design: I don’t think my custom appender should care about layout, since really it just needs to pass or not pass the log event along. Also, this approach requires two custom classes, and one of them (mystuff.FilteredAppender) adds no value at all — it’s only there to hold the custom Filter.

I’d love to do something much cleaner like…

    <logger name="org.restlet.Component.LogService">
            <filter class="mystuff.EventFilter"/>
    </logger>

…but this is apparently not supported by the log4j framework.

Is there a good clean way to do event filtering the way I want to do it?

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

    This message board entry describes a solution I was able to get working. It seems a shame to have to use an AsyncAppender as the filter holder, but it looks like that’s the best option w/o creating a new custom Appender. So I end up with:

        <appender name="filtered" class="org.apache.log4j.AsyncAppender">
                <filter class="mystuff.EventFilter"/>
                <appender-ref ref="ASYNC"/>
        </appender>
    
        <logger name="org.restlet.Component.LogService" additivity="false">
                <appender-ref ref="filtered"/>
        </logger>
    

    But I’d certainly be interested if anyone knows of a still better approach. 🙂

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

Sidebar

Related Questions

How can I filter logging based on a logged exception's message? Code looks like
How do I filter log messages from external third party frameworks? I am using
I would like to filter an array of items by using the map() function.
I would like to filter NSMutableArray elements that contains some string. ListArchives is filled
I have a CSV file and I would like to filter all the lines
I have set of 6 elements and I would like to filter by every
Given a set of phrases, i would like to filter the set of all
I have a column 'date' in my DataSet. I would like to filter this
I would like to create kind of a before filter which allows me to
I would like to know how I can do a low-pass filter in opencv

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.