c# - how to set custom value in log4net.config -
i have custom appender in dll , want set value "element.machinename" inside log4net.config file.
it works static value : <appname ="somename" />
how can set value element.machinename ?
<appender name="someappender" type="consoleapplication1.someappender"> <appname value="somename"/> <host value="how set host variable?" /> <layout type="log4net.layout.layoutpattern"> <conversionpattern value="[%date{mm/dd/yyyy hh:mm:ss tt}] %property{hostname} [%-5level] [%class]-[%method] - [%message] %newline" /> </layout> </appender>
you use global context purpose. see this log4net page, explains how can set properties. in settings use this:
<appender name="someappender" type="consoleapplication1.someappender"> <file value="log\sessions\%property{logfilename}.log" /> <maxfiles value="1000" /> <layout type="log4net.layout.patternlayout" value="%date %-5level - %message%newline" /> </appender>
Comments
Post a Comment