This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Question about log4j.properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Question about log4j.properties " Watch "Question about log4j.properties " New topic
Author

Question about log4j.properties

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5126
    
  12

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!


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Threshold represents the minimum Level/Priority accepted, not an absolute Level/Priority.

How about custom filters?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5126
    
  12

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

Joined: Oct 10, 2000
Posts: 1364
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
Bartender

Joined: Jul 19, 2004
Posts: 5126
    
  12

thanks for the info

i'll see what i can do with that one
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5126
    
  12

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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about log4j.properties
 
Similar Threads
what is log4j.properties , why we need this. how to create this in java project using eclipse IDE
log4j DailyRollingFileAppender not creating new files
Issues logging with log4j
log4j output file
server could not started