logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kindaian@gmail.com" <kinda...@gmail.com>
Subject Visual Basic 2008 app.config errors...
Date Sun, 31 Aug 2008 23:48:46 GMT
Hi everyone,

I've a project in vb.net 2008 running, and i added log4net to it.

It was an issue to sort out what to do to add logging to the project but 
nothing special that some google couldn't help sort out.

The bigger issues where mainly what to add to app.config:

<configuration>
  <configSections>
    <section name="log4net" 
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, 
Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905" />
  </configSections> 
  <log4net debug="true">
    <appender name="RollingLogFileAppender" 
type="log4net.Appender.RollingFileAppender">
      <file value="C:\\TestLog.txt" />
      <appendToFile value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="10MB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - 
%m%n" />
      </layout>
    </appender>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="RollingLogFileAppender" />
    </root>
  </log4net>
 
  <system.diagnostics>.....</system.diagnostics>
</configuration>

Then i got info messages regarding the invalidity of the <log4net> entries.

To sort that out, i added the schema for log4net in the same directory 
as the DotNetConfig.xsd (which on my computer was located in C:\Program 
Files\Microsoft Visual Studio 9.0\Xml\Schemas).

The file has the following content (feel free to correct the entries as 
i only sorted them out for a non-message situation of notice the file, 
appendToFile, rollingStyle, mazSizeRoolBackups, maximumFileSize, 
staticLogFileName, layout and conversionPattern where adapted by me from 
the original i used from Jerry Wang):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
     <!--<xs:annotation>
           This schema was written by Jerry Wang, Please retain this 
annotation.
          </xs:annotation>-->

    <xs:element name='log4net'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='appender' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='root' />
                <xs:element ref='logger' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='renderer' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='param' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='debug' />
            <xs:attribute name='update' />
            <xs:attribute name='threshold' />
        </xs:complexType>
    </xs:element>

    <xs:element name='appender'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='param' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='file' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='appendToFile' minOccurs='0' 
maxOccurs='unbounded' />
       
                <xs:element ref='rollingStyle' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='maxSizeRollBackups' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='maximumFileSize' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='staticLogFileName' minOccurs='0' 
maxOccurs='unbounded' />
       
       
                <xs:element ref='appender-ref' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='filter' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='layout' />
            </xs:sequence>
            <xs:attribute name='name' use='required' />
            <xs:attribute name='type' use='required' />
        </xs:complexType>
    </xs:element>

    <xs:element name='filter'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='param' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='type' use='required' />
        </xs:complexType>
    </xs:element>

    <xs:element name='root'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='level' />
                <xs:element ref='appender-ref' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='param' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name='logger'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='level' />
                <xs:element ref='appender-ref' minOccurs='0' 
maxOccurs='unbounded' />
                <xs:element ref='param' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='name' use='required' />
            <xs:attribute name='additivity' />
        </xs:complexType>
    </xs:element>

    <xs:element name='level'>
        <xs:complexType>
            <xs:attribute name='value' use='required' />
        </xs:complexType>
    </xs:element>

    <xs:element name='appender-ref'>
        <xs:complexType>
            <xs:attribute name='ref' use='required' />
        </xs:complexType>
    </xs:element>

    <xs:element name='param'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='param' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='name' use='required' />
            <xs:attribute name='value' />
            <xs:attribute name='type' />
        </xs:complexType>
    </xs:element>

<xs:element name='file'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='file' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='value' use='required' />
        </xs:complexType>
    </xs:element> 
 
  <xs:element name='appendToFile'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='appendToFile' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='value' use='required' />
        </xs:complexType>
    </xs:element> 
 
  <xs:element name='rollingStyle'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='rollingStyle' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='value' use='required' />
        </xs:complexType>
    </xs:element> 

  <xs:element name='maxSizeRollBackups'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='maxSizeRollBackups' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='value' use='required' />
        </xs:complexType>
    </xs:element> 

  <xs:element name='maximumFileSize'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='maximumFileSize' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='value' use='required' />
        </xs:complexType>
    </xs:element> 

  <xs:element name='conversionPattern'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='conversionPattern' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='value' use='required' />
        </xs:complexType>
    </xs:element> 

  <xs:element name='staticLogFileName'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='staticLogFileName' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='value' use='required' />
        </xs:complexType>
    </xs:element> 
 
    <xs:element name='renderer'>
        <xs:complexType>
            <xs:attribute name='renderingClass' use='required' />
            <xs:attribute name='renderedClass' use='required' />
        </xs:complexType>
    </xs:element>

    <xs:element name='layout'>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref='param' minOccurs='0' 
maxOccurs='unbounded' />
                 <xs:element ref='conversionPattern' minOccurs='0' 
maxOccurs='unbounded' />
            </xs:sequence>
            <xs:attribute name='type' use='required' />
        </xs:complexType>
    </xs:element>

</xs:schema>

Then i added the schema to DotNetConfig.xsd as follows:

<?xml version="1.0" encoding="us-ascii"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:vs="http://schemas.microsoft.com/Visual-Studio-Intellisense"
elementFormDefault="qualified" attributeFormDefault="unqualified" 
vs:helpNamespace="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <xs:include schemaLocation="log4net.xsd" />
   [............]

At the end, i managed to remove all the info and warnings, without an 
issue. I think only that the log4net schema should be expanded/improved 
by more xml experts then me.

Hope that this be of help for some other users...

Cheers,
Kindaian


Mime
View raw message