Forum Stats

  • 3,837,206 Users
  • 2,262,235 Discussions


Doubt in properties file updation

807569 Member Posts: 34,691
edited May 15, 2006 6:12AM in Java Programming
I am posting this message in this forum, since It is a core Java question, however I am facing this problem while doing log4j implementation.

I have a web application in which i am using log4j for logging. I have specified the config entries for a class like following:, TestLog
log4j.appender.TestLog.layout.ConversionPattern=[%5p] %d{dd MMM yyyy HH:mm:ss,SSS} [%C] - %m%n
Now I have to give the user, an option to change the logging level from the GUI. Now If the user changes the log level from DEBUG to ERROR then I need to update the corresponding entry in the config file also.
I have a set of 4-5 classes for which I have to change the log level in the log4j config entries, since I am using different log files fro different classes.

Can anyone let me know that how can I do this???

Thanks in Advance
Inder Jeet Singh


  • 807569
    807569 Member Posts: 34,691
    The file is just a Java properties file, which you can load and save using the java.util.Properties class.

    If you want to change the logging level on the fly (while the program is running), you can do that too with Log4J - look at the API documentation of Log4J, I'm sure it's described in there.
  • 807569
    807569 Member Posts: 34,691
    I know it is a Java properties file but I have to change the value at more than one places simultaneously and there are two values seperated by a comma(,), out of which only one I need to change. I would like to know that what is most efficient way of changing it.

    The other thing is I know that we can change the log level using log4j on the fly, but that we have to do it programatically not manually based on the input seletedt by the user.
This discussion has been closed.