0

I have a custom appender in another dll and I want to set a value "Element.MachineName" inside the log4net.config file.

It works with a static value like : <appName ="SomeName" /> but how can I set this value with Element.MachineName ?

<appender name="SomeAppender" type="ConsoleApplication1.SomeAppender">
    <appName value="someName"/>
    <host value="how to set the host to this variable?" />
        <layout type="log4net.Layout.LayoutPattern">
          <conversionPattern value="[%date{MM/dd/yyyy hh:mm:ss tt}] %property{HostName} [%-5level] [%class]-[%method] - [%message] %newline" />
        </layout>
  </appender>
n3tx
  • 429
  • 2
  • 10
  • 23

1 Answers1

3

You could use the global context for this purpose. See this log4net page, it explains how you can set the properties. In your settings you could use something like this:

<appender name="SomeAppender" type="ConsoleApplication1.SomeAppender">
  <file value="Log\Sessions\%property{LogFileName}.log" />
  <maxFiles value="1000" />
  <layout type="log4net.Layout.PatternLayout" value="%date %-5level - %message%newline" />
</appender>
Stormer
  • 76
  • 4