File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 4907
    
  10

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: 4907
    
  10

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: 4907
    
  10

thanks for the info

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

Joined: Jul 19, 2004
Posts: 4907
    
  10

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
log4j output file
server could not started
Issues logging with log4j
what is log4j.properties , why we need this. how to create this in java project using eclipse IDE
log4j DailyRollingFileAppender not creating new files