0

Do you have any idea why New-Logger function doesn't work when log4net debug mode is on? ie. when

<log4net debug="true">
...
</log4net>

When I change debug attribute in the sample code found at Trying to get log4net working with PowerShell (with a log4net config file in the mix) I get the following trace:

log4net: Configuration update mode [Merge].
log4net: Logger [root] Level string is [ALL].
log4net: Logger [root] level set to [name="ALL",value=-2147483648].
log4net: Loading Appender [LogFileAppender] type: [log4net.Appender.FileAppender]
log4net: Setting Property [File] to String value [C:\Users\XXX\Documents\Snippets\LOGS\LogTest2.txt]
log4net: Setting Property [AppendToFile] to Boolean value [True]
log4net: Converter [message] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [newline] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Setting Property [ConversionPattern] to String value [%date [%thread] %-5level %logger [%ndc] - %message%newline]
log4net: Converter [date] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [literal] Option [ [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [thread] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [literal] Option [] ] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [level] Option [] Format [min=5,max=2147483647,leftAlign=True]
log4net: Converter [literal] Option [ ] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [logger] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [literal] Option [ [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [ndc] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [literal] Option [] - ] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [message] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [newline] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Setting Property [Layout] to object [log4net.Layout.PatternLayout]
log4net: Opening file for writing [C:\Users\XXX\Documents\Snippets\LOGS\LogTest2.txt] append [True]
log4net: reated Appender [LogFileAppender]
log4net: Adding appender named [LogFileAppender] to logger [root].
log4net: Retrieving an instance of log4net.Repository.Logger for logger [new-presentation].
log4net: Setting [new-presentation] additivity to [True].
log4net: Logger [new-presentation] Level string is [ALL].
log4net: Logger [new-presentation] level set to [name="ALL",value=-2147483648].
log4net: Adding appender named [LogFileAppender] to logger [new-presentation].
log4net: Hierarchy Threshold []
Method invocation failed because [System.Object[]] doesn't contain a method named 'Info'.
At C:\Users\XXX\Documents\Snippets\Sample.ps1:58 char:10
+ $Log.Info <<<< ($MsgTable.StartMsg)
+ CategoryInfo          : InvalidOperation: (Info:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

Method invocation failed because [System.Object[]] doesn't contain a method named 'Info'.
At C:\Users\XXX\Documents\Snippets\Sample.ps1:68 char:10
+ $Log.Info <<<< ($MsgTable.StopMsg)
+ CategoryInfo          : InvalidOperation: (Info:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Community
  • 1
  • 1
utom
  • 482
  • 1
  • 3
  • 15
  • Please, explain what "doesn´t work" means. Include any error messages you see and post more code if relevant. Also, describe your attempts to solve the problem and how the link you have included doesn't provide a solution. – Mark May 30 '13 at 14:46
  • The example code used in [Trying...](http://stackoverflow.com/questions/13496363/trying-to-get-log4net-working-with-powershell-with-a-log4net-config-file-in-the) works unless you add the debug="true". When I set the debug attribute to "true" in config xml file I recieve the trace: `... Method invocation failed because [System.Object[]] doesn't contain a method named 'Info'. At C:\Users\XXX\Documents\Snippets\Sample.ps1:58 char:10 + $Log.Info <<<< ($MsgTable.StartMsg) + CategoryInfo : InvalidOperation: (Info:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound` – utom May 30 '13 at 17:18

0 Answers0