views:

216

answers:

1

I have a console application that should do best effort logging to a database in addition to flat files. When there is no network connectivity (and therefore no connection to the database) log4net prints an error.

log4net:ERROR [AdoNetAppender] Could not open database connection [Data Source=...]
System.Data.SqlClient.SqlException: A network-related or instance-specific 
error occurred while establishing a connection to SQL Server. The server 
was not found or was not accessible. Verify that the instance name is correct 
and that SQL Server is configured to allow remote connections. (provider: 
Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at ...

I don't want to see that error in the console. Is there any way to suppress internal log4net error messages? Recompile would be ok, but I would prefere a config based setting, if possible.

+3  A: 

I haven't tested it out, but I'm pretty sure the QuietMode property does what you want.

Mark Rushakoff
Yes!<configuration> <appSettings> <add key="log4net.Internal.Quiet" value="true" /> </appSettings></configuration>Did the trick for me! Thanks!
Tobias Hertkorn