Why Log4net does not log in PowerGUI?

272 Views Asked by At

I use log4net as logger and here is my appender:

<appender name="ConsoleAppender"
        type="log4net.Appender.ConsoleAppender">
<threshold value="INFO"/>
<layout type="log4net.Layout.PatternLayout">
  <conversionPattern value="%message%newline" />
</layout>

In my case I write a powershell commandlet and logs into the powershell, but not if I use the powergui. Should I use an other appender? Someone could help me mange that it logs in the power gui?

1

There are 1 best solutions below

1
On

Most likely, log4net is looking in the current working directory for the configuration file, but your working directory is different when you're in PowerGui vs. in the console.

Use set-location at the beginning of your script to change to the appropriate directory.