• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to change xml attribute values with dom, or sax or jaxp?

 
umasankar puranam
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers,

I am having an xml file as shown below



I want to change the value of param tags attribute value to "WARN" with name="Threshold".

Please provide me the code to do this using dom, or sax, or jaxp apis.

Thanks & Regards,
UmaSa
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems like you are trying to change the log4j configuration at runtime , its not advisable.

Anyways if you want to change XML using program , then you might want to read the xml onto a DOM object and then changes the required attribute and then again serialize it to XML.
 
umasankar puranam
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Rahul Bhattacharjee,

Do you mean we should not change the log levels dynamically or the approach that I am thinking is not currect. If my approach is not currect please suggest me a way to CHANGE THE LOG LEVELS DYNAMICALLY.

Thanks & Regards,
UmaSankar.P
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its not advisable to changes log level dynamically.
But you can try that out as mentioned in my first post.

You might have to use configure method again after changing the log4j configuration file so that the log4j system takes the changes.
 
umasankar puranam
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Rahul Bhattacharjee,

Please provide the sample code snippets to change the log levels dynamically.

Thanks & Regards,
UmaSankar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic