Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top