...::...

 

Home
Eggdrop
TCL
Webpages
Sonstiges
Links
Kontakt
Gameserver
Linux
Forum

 (c) robkey.de
2003-2011

 

LOG4NET - EXAMPLE
by robkey.de

log4net is a nice logging dll. in this example you will see how to use it for fileappends.

Release Date:
22.09.2008

Latest Major Release:
22.09.2008 Version 0.0.1

Codezeilen:
1364

Platform:
Visual Basic.NET 2003

Download Example:
LogDemo.rar


how to use it?
download
http://logging.apache.org/log4net/downloads.html

and import it in your Visual Basic.net application

edit these files:

app.config
Code:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <configSections>
      <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
   </configSections>
   
   <log4net>
<appender name="FileAppender" type="log4net.Appender.FileAppender">
   <file value="log-file.txt" />
   <appendToFile value="true" />
   <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
   </layout>
</appender>   
 
      <root>
         <level value="ALL" />
         <appender-ref ref="FileAppender" />
      </root>
  </log4net>


</configuration>



form1.vb

Code:

Imports log4net
Imports log4net.Config
Imports log4net.Appender
Imports log4net.Core

' Configure log4net using the .config file
<Assembly: log4net.Config.XmlConfigurator(Watch:=True)>


....

public class xxx
  Dim log As ILog = LogManager.GetLogger(GetType(form1)
....


private sub xxx
  log.Info("Programstart")
...




more documentation:
http://logging.apache.org/log4net/release/manual/configuration.html

(c) Robkey.de 2003-2011,  (zurück zur Startseite)

robkey.de