Skip to content

Commit

Permalink
Fix AdoNetAppender using npgsql
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsar Nikolay committed Dec 8, 2020
1 parent dbad144 commit 634ffca
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/log4net/Appender/AdoNetAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,17 @@ protected virtual void SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
{
dbCmd.Transaction = dbTran;
}
// prepare the command, which is significantly faster
dbCmd.Prepare();

try
{
// prepare the command, which is significantly faster
dbCmd.Prepare();
}
catch (Exception)
{
// ignore prepare exceptions as they can happen without affecting actual logging, eg on npgsql
}

// run for all events
foreach (LoggingEvent e in events)
{
Expand Down

0 comments on commit 634ffca

Please sign in to comment.