c# - log4net %property does not work -
i have small test project following code:
class program { static void main(string[] args) { log4net.globalcontext.properties["logfilename"] = "log.txt"; log4net.config.xmlconfigurator.configure(new system.io.fileinfo("log4net.xml")); log4net.ilog logger = log4net.logmanager.getlogger("tests"); logger.debug("test message"); } }
my log4net.xml config file has following content:
<?xml version="1.0" encoding="utf-8" ?> <log4net> <appender name="rollingfileappender" type="log4net.appender.rollingfileappender"> <file value="%property{logfilename}" /> <appendtofile value="true" /> <rollingstyle value="size" /> <maxsizerollbackups value="10" /> <maximumfilesize value="100kb" /> <staticlogfilename value="true" /> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%utcdate{iso8601} [%level][%logger] %message%newline" /> </layout> </appender> <root> <level value="all" /> <appender-ref ref="rollingfileappender" /> </root> </log4net>
my question why log4net create file name %property{logfilename} , doesn't substitutes log.txt?
log4net library taken nuget (id:log4net version:2.0.3).
please use in xml config
<file type="log4net.util.patternstring" value=".\%property{logfilename}" />
Comments
Post a Comment