Maybe I'm wrong, but you are already using parameters, so there is no risk of SQL injection. @message is passed as a separate SQL parameter using log4net, not through string concatenation.
But if you are afraid of SQL injection, what about using a stored procedure ...?
Edit Don't be afraid, dear OP. Here is the missing evidence that the log4net logging mechanism is safe for SQL injection:
Records are written to the database either using a prepared statement or using a stored procedure. The CommandType property is set to Text (System.Data.CommandType.Text) to indicate the prepared statement or StoredProcedure (System.Data.CommandType.StoredProcedure) to indicate the stored procedure.
So, prepared -> precompiled -> safe parameter assignment.
If you need more information, you can find it here .
source share