Context: I'm developing a VB.Net windows application that uses the log4net framework. I have a Logger class that is the interface with the log4net f/w
Issue: My log4net configuration needs to be specified in a config other than my app.config. This, however is not happening. Description: I had earlier put in my config in the App.Config. This is not being read at all, apparently due to some appsettings parameters. Query: Is there anything specific I need to do to enable this? If not, then I'd like to move my configuration in some logging.config file. However, I have been unable to find in the documentation on how to actually set the file path and where to set it in the code. Would we need to do this in every function where we are using the log.debug etc methods? http://logging.apache.org/log4net/release/manual/configuration.html This link states that we can do it. But I'm stuck up on where to do this sort of stuff. Code: Imports log4net Imports log4net.Appender Imports log4net.Config Public Class Logger Dim loggerError As log4net.ILog = LogManager.GetLogger("LogError") Private Sub logError(ByVal strMsg As String, ByVal e As System.Exception) If loggerError.IsErrorEnabled Then loggerError.Error("[" + DateTime.Now.ToString() + "] " + extractInfo(strMsg), e) End If End Sub End Class Config: <appender name="ErrorRollingFileAppender" type="log4net.Appender.RollingFileAppender">appender name="ErrorRollingFileAppender" type="log4net.Appender.RollingFileAppender"> <param name="File" value="Error.log" /><param name="File" value="Error.log" /> <param name="AppendToFile" value="true" /><param name="AppendToFile" value="true" /> <param name="MaxSizeRollBackups" value="10" /><param name="MaxSizeRollBackups" value="10" /> <param name="MaximumFileSize" value="1000" /><param name="MaximumFileSize" value="1000" /> <param name="RollingStyle" value="Size" /><param name="RollingStyle" value="Size" /> <param name="StaticLogFileName" value="true" /><param name="StaticLogFileName" value="true" /> <layout type="log4net.Layout.PatternLayout"><layout type="log4net.Layout.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p %-45c [%x] - %m%n" /><param name="ConversionPattern" value="%d [%t] %-5p %-45c [%x] - %m%n" /> </layout></appender> <logger name="LogError"> <level value="ERROR" /> <appender-ref ref="ErrorRollingFileAppender" />logger name="LogError"> <level value="ERROR" /> <appender-ref ref="ErrorRollingFileAppender" /><level value="ERROR" /> <appender-ref ref="ErrorRollingFileAppender" /><appender-ref ref="ErrorRollingFileAppender" /> </logger> Cheers! Piyush
