I decided to use log4net as a registrar for a new webservice project. Everything works fine, but I get a lot of messages like the following for every log4net tag that I use in my web.config :
Could not find schema information for element 'log4net' ...
Below are the relevant parts of my web.config :
<configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> </configSections> <log4net> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="C:\log.txt" /> <appendToFile value="true" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="10" /> <maximumFileSize value="100KB" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level: %message%newline" /> </layout> </appender> <logger name="TIMServerLog"> <level value="DEBUG" /> <appender-ref ref="RollingFileAppender" /> </logger> </log4net>
It is decided:
- Copy each log4net tag to a separate
xml file. Be sure to use .xml as the file extension. - Add the following line to
AssemblyInfo.cs :
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "xmlFile.xml", Watch = true)]
nemo added:
Just a warning word, follow the recommendations of the responses to this thread. There is a security risk using the log4net configuration in xml from the root of the web service, as this will be accessible to everyone by default. Just if your configuration contains sensitive data, you might want to put it another way.
@wcm: I tried using a separate file. I added the following line to AssemblyInfo.cs
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
and put everything related to log4net in this file, but I still get the same messages.
logging web-services web-config schema log4net
xsl Oct 06 '08 at 14:11 2008-10-06 14:11
source share