#log4net4 配置文件路径
$log4netconifg = (pwd).ToString() + "\test.log4net.config"
[System.Reflection.Assembly]::LoadWithPartialName("log4net")
$file = new-Object System.Io.FileInfo($log4netconifg)
[log4net.Config.DOMConfigurator]::ConfigureAndWatch($file);
$log = [log4net.LogManager]::GetLogger($null)
$log.Debug("测试")
[log4net.LogManager]::ShutDown()
$log4netconifg = (pwd).ToString() + "\test.log4net.config"
[System.Reflection.Assembly]::LoadWithPartialName("log4net")
$file = new-Object System.Io.FileInfo($log4netconifg)
[log4net.Config.DOMConfigurator]::ConfigureAndWatch($file);
$log = [log4net.LogManager]::GetLogger($null)
$log.Debug("测试")
[log4net.LogManager]::ShutDown()
首先使用LoadWithPartialName把log4net加载进来,然后使用ConfigAndWatch配置一下,就可以用了
使用的时候把log4net.dll加入到GAC,在脚本相同目录放一个test.log4net.config。
相关链接:
http://www.microsoft.com/powershell
http://logging.apache.org/log4net/