Hi !
 
1)
 
Before you set:
Private ReadOnly log As ILog = LogManager.GetLogger(GetType(xxxx))
 
you have to initialize log4net. You may do this in your constructor or in
the firstline, your sub main excutes [sorry, I have no clue about statements
in VB ;-) ]. There are also examples on the log4net homepage.
 
In C#, I do this:
 
  log4net.Config.XmlConfigurator.ConfigureAndWatch
   (
    new FileInfo(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile)
   );
 
after this, you'll create a logger:

 this.logger = log4net.LogManager.GetLogger(typeof(SimpleLoggingExample));
 

2)
 
May be I am not the hyper-expert, but I think, you can't.
 
What I do, is using an assembly attribute, like this:
 
[assembly: log4net.Config.XmlConfigurator(ConfigFileExtension="l4n",
Watch=true)]

 
In this case, log4net would use your apps's path and name, but expecting an
extension of "l4n" [you may place xml here]. There are other attributes
alos, but I do not remember them this moment.
 
May be, this helps a bit.
Don't worry, after the beginning, you'll love log4net!
 
Regards,
mabra
 

  _____  

From: Y U [mailto:[email protected]] On Behalf Of Information
Vision
Sent: Wednesday, March 10, 2010 8:44 PM
To: [email protected]
Subject: Frist time user needs advise



Hi

 

I have  a vb.net winform app that uses SUB Main in module modMain as
start-up.

 

I have copied log4net.dll and log4net.xml files to the application main
folder. I have added log4net.dll to application references.

 

I have added below configuration in file Logging.Xml and have placed it in
the application main folder. 

 

Logging.Xml -- BEGIN

<log4net>

    <appender name="Console" type="log4net.Appender.ConsoleAppender">

        <layout type="log4net.Layout.PatternLayout">

            <!-- Pattern to output the caller's file name and line number
-->

            <conversionPattern value="%5level [%thread] (%file:%line) -
%message%newline" />

        </layout>

    </appender>

    

    <appender name="RollingFile"
type="log4net.Appender.RollingFileAppender">

        <file value="example.log" />

        <appendToFile value="true" />

        <maximumFileSize value="100KB" />

        <maxSizeRollBackups value="2" />

 

        <layout type="log4net.Layout.PatternLayout">

            <conversionPattern value="%level %thread %logger -
%message%newline" />

        </layout>

    </appender>

    

    <root>

        <level value="DEBUG" />

        <appender-ref ref="Console" />

        <appender-ref ref="RollingFile" />

    </root>

</log4net>

Logging.Xml -- END

 

My questions are;

 

1. In modMian I added the following line

 

Private ReadOnly log As ILog = LogManager.GetLogger(GetType(xxxx))

 

What do I enter in place of xxxx?

 

2. How do I tell my app to use Logging.Xml for configuration from the
application main folder?

 

Thanks

 

Regards

 

 

Yahya

 

 

Reply via email to