2

I recently read that it is possible to define the Log4Net Config XML in defining this file in a class attribute.

<Assembly: log4net.Config.XMLConfigurator(ConfigFile:="Log4Net.Config.xml", Watch:=True)>

How can I define this file using only pure VB.Net code without using Attribute technique ?

Example (this is only textuals examples)

log4net.Config.OpenFile("Log4Net.Config.xml")
log4net.OpenConfigFile("Log4Net.Config.xml")
log4net.InitLoggingConfigFile("Log4Net.Config.xml")

The configuration's file already exists. I search only the code that read it to configure logging.

Ann L.
  • 13,760
  • 5
  • 35
  • 66
schlebe
  • 3,387
  • 5
  • 37
  • 50
  • Does this answer your question? [Log4Net in a separate configuration file](https://stackoverflow.com/questions/32892021/log4net-in-a-separate-configuration-file) – Tu deschizi eu inchid Dec 28 '22 at 15:35
  • The following may be of interest: https://blog.elmah.io/log4net-tutorial-the-complete-guide-for-beginners-and-pros/ and https://stackoverflow.com/questions/73759817/built-a-service-but-memory-keeps-climbing/73806343#73806343 – Tu deschizi eu inchid Dec 28 '22 at 15:39

1 Answers1

1

To solve your issue, you can use XmlConfigurator.Configure() function

XmlConfigurator.Configure(new System.IO.FileInfo(args[0])); 

that is explained on Apache Net4Net site

tramex
  • 149
  • 6