1

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?

Patrick
  • 621
  • 2
  • 7
  • 21
  • Did you ever find a solution? I have a ConsoleAppender defined which works under powershell but not powershell ise. What's going on with ISE that prevents log4net's ConsoleAppender from working? – albvar Jan 30 '19 at 23:35
  • You are correct, it happens also in the PowerShell ISe, I have not found a solution for that, I am sorry. – Patrick Jan 31 '19 at 14:11

1 Answers1

1

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.

alroc
  • 27,574
  • 6
  • 51
  • 97
  • I did `set-location ` but nothing special happened. Did I selected the wrong direcotry, which specific directory do I have to choose? Which files should be in their? Another smoother way does not exist? Maybe another appender which could manage this alone, without any movements by the user? – Patrick Dec 16 '13 at 13:16