How to implement PropertyDefiner for logback to access multiple properties -
i define properties in logback.xml config file , saw implementing propertydefiner great way set properties in customizable way.
after starting implement began wonder how access value of name attribute of element within tag. i'm not seeing anyway , i'm scratching head. propertydefiner make create new implementation every single property? why not hard code it? didn't see discussion out on web.
i hope i'm not seeing , brains of stackoverflow can me out. know how this? thanks!
i found discussion: same question asked, no answer returned.
fyi: want customize how properties because pulling database. have helper class pulls properties in on server startup. these properties vary based on environment (dev, test, prod, etc.)
as of logback version 1.0.6, value of name attribute cannot accessed directly. however, nothing prevents passing value of name attribute in property of choice. example:
<define name="rootlevel" class="your.propertydefiner"> <mykey>rootlevel</mykey> </define>  where mykey property of your.propertydefiner. example:
class your.propertydefiner implements propertydefiner { string mykey; public void setmykey(string k) { this.mykey= k; } public string getpropertyvalue() { return ... } }  joran, logback's configuration framework, takes care of wiring. joran inject value of mykey element mykey property of your.propertydefiner. if curious technical details, see documentation on implicit actions , implicit actions in practice. 
Comments
Post a Comment