Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Visual Basic 2008 app.config errors...
Prev Next
You are not authorized to post a reply.

Author Messages
kindaian@gmail.com

09/01/2008 1:48 AM  

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

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Visual Basic 2008 app.config errors...



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement