Still not working damn!
Now I understood: in the app.config I have to add the log4net configuration tags.
You suggest me to place as priority ERROR so that only errors will be displayed.
I try to copy and past what I found in the web(
http://wiki.nhibernate.org/display/NH/C ... et+Logging)
Code:
<!-- This section contains the log4net configuration settings -->
<log4net debug="false">
<!-- Define some output appenders -->
<appender name="trace" type="log4net.Appender.TraceAppender, log4net">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%P{user}&gt; - %m%n" />
</layout>
</appender>
<appender name="console" type="log4net.Appender.ConsoleAppender, log4net">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%P{user}&gt; - %m%n" />
</layout>
</appender>
<appender name="rollingFile" type="log4net.Appender.RollingFileAppender,log4net" >
<param name="File" value="log.txt" />
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy.MM.dd" />
<param name="StaticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{user}&gt; - %m%n" />
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default priority -->
<root>
<priority value="INFO" />
<appender-ref ref="console" />
</root>
</log4net>
I also added the
Code:
log4net.Config.XmlConfigurator.Configure();
line on the application code.
But I recived an expetion:
Error: System.TypeInitializationException: The type initializer for 'NHibernate.Cfg.Configuration' threw an exception. ---> System.TypeInitializationException: The type initializer for 'log4net.Core.LoggerManager' threw an exception. ---> System.TypeInitializationException: The type initializer for 'log4net.Util.LogLog' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section log4net. (c:\Project\RegistrazioniMagazzino\RegistrazioniMagazzino\bin\Debug\RegistrazioniMagazzino.vshost.exe.config line 30)
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)Then I deleted all the
appender tags leaving only:
Code:
<!-- This section contains the log4net configuration settings -->
<log4net debug="false">
<root>
<priority value="ERROR" />
<appender-ref ref="console" />
</root>
</log4net>
But still have the same error.
If I remove all the log4net tags I receive no error (but I have the default inizialization from NHibernate as before so that I have it enable agian!)
Thanks for any other help you can give me.
ema