Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Log4J: 2 Appenders - one gets errors, other gets all (doesn't work)

I sent a message to the log4j-user mailing list this afternoon, but have not received a response - so hopefully someone can help me out. Here's the problem I'm having:

I have two appenders - a console and a file.  I want all messages to 
go to the console and only <= error to go to the file.

In my file appender, I have a filter to only get the error messages:

<filter class="org.apache.log4j.varia.LevelRangeFilter">
  <param name="LevelMax" value="ERROR" />
</filter>

Then in <root> I have:

  <root>
    <level value="DEBUG"/>
    <appender-ref ref="CONSOLE"/>
    <appender-ref ref="FILE"/>
  </root>

From the documentation I've read (i.e. http://tinyurl.com/meef), this
*should* work.  However, all messages get logged to both the console
appender and the file appender.

Any advice is appreciated.

Posted in Java at Sep 05 2003, 10:11:38 PM MDT 6 Comments
Comments:

Forget the filter. just add a threshold to your appender. <param name="Threshold" value="error" /> If you wanted JUST error it wouldn't work, because fatal gets selected to. For that you would need a filter.

Posted by Yuri on September 07, 2003 at 04:25 AM MDT #

I want fatal and error - that's why I'm using a filter.

Posted by Matt Raible on September 07, 2003 at 04:38 PM MDT #

mh, if you want log >= error go to the file (is it correct? Do you want error and fatal, right?) threshold="ERROR" is the corect setting. Threshold select the minimum severity to be logged, you need a filter only if you need to include specific severities (not >= x). Your current setting, filter LevelMax=ERROR, includes everything from debug to error (fatal is > error, remember)

Posted by Fabrizio Giustina on September 08, 2003 at 08:21 AM MDT #

Matt, I don't know this filter stuff in log4j (yet), but my gutt feeling tells me you should set LevelMin to ERROR instead of LevelMax. Does this make sense? It seems to be done that way in the email you're referring to too...

Posted by Tom Klaasen on September 08, 2003 at 09:05 AM MDT #

Tom - you were correct - my conception of Min and Max in Log4j was back-asswards. Thanks - your suggestion worked.

Posted by Matt Raible on September 08, 2003 at 06:56 PM MDT #

Its still a bit strange to use a filter when the Appenders already support this. But hey, whatever floats your boat.

Posted by Unknown on September 09, 2003 at 01:37 PM MDT #

Post a Comment:
  • HTML Syntax: Allowed