Logging from powershell-script to csharp-program (log4net – logfile)

Question:

I have written a program with C#, that creates a logfile and fills this by using log4net. This program starts powershell-scripts. The scripts should use log4net, too. I want to monitor what the scripts log to log4net while they are running and write this information in my logfile.

Have you an idea how I do this or where I get information/help to my problem?

thanks

Answer:

You could define some functions and pass them to your script as variables:


Then you can invoke the function from the script like this:

EDIT: to add a logging level, you should do something like

Source:

Logging from powershell-script to csharp-program (log4net – logfile) by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply