Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about log4j.properties

 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my log4j.properties file



when i write log.info("") it's also written into the file with Treshold=DEBUG . Is it possible to get it configured so that in file with Treshold=DEBUG only these messages appear that are the result of a log.debug("").

Thanks in advance!
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Threshold represents the minimum Level/Priority accepted, not an absolute Level/Priority.

How about custom filters?
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made just an append text-file and write to that one, because it must be RAD.

Any examples of such implementation of a custom filter?
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'll let you do the legwork, but I did find a little more info for you.

Here's a quote from Ceki G�lc�'s The complete log4j manual,


If you must absolutely filter events by exact match, then you can attach a LevelMatchFilter to a given appender in order to filter out logging events by exact level match. The LevelMatchFilter is an instance of a custom filter.
...
Note that the PropertyConfigurator does not support custom filters which can only be specified in configuration scripts expressed in XML format.
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the info

i'll see what i can do with that one
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found a solution: just stopped with using the log4j.properties file and use a log4j.xml file instead. Here you can add a filter to your appender eand this is not an option with the .properties file

Example to only allow info messages:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic