Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3969392
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:57:30+00:00 2026-05-20T03:57:30+00:00

Is there an accepted way to both use the log4net ado provider and guard

  • 0

Is there an accepted way to both use the log4net ado provider and guard against SQL injection? I can do my own hand rolled scrubbing methods, but that strikes me as risky.

Is there some kind of “DontLetPeopleOwnMyDatabase” = true setting?

our current dangerous config:

<appender name="ADONetAppender" type="log4net.Appender.ADONetAppender">
  <threshold value="ERROR"/>
  <bufferSize value="1"/>
  <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
  <connectionString value="server=myDBServer; uid=myuserName; pwd=myPassword; database=myDatabase"/>
  <commandText value="INSERT INTO errorlog([message], [ServerName], [ApplicationName]) VALUES(@message, 'myServer', 'myApp')" />
  <parameter>

    <parameterName value="@message"/>

    <dbType value="String"/>

    <size value="4000"/>

    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%message"/>
    </layout>

  </parameter>
</appender>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:57:30+00:00Added an answer on May 20, 2026 at 3:57 am

    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 by log4net, not through string concatenation.

    But if you are that afraid about SQL injection, how about using a stored procedure…?

    Edit Fear no more, dear OP. Here is the missing proof that the log4net logging mechanism is safe against SQL injection:

    Records are written into the database either using a prepared statement or a stored procedure. The CommandType property is set to Text (System.Data.CommandType.Text) to specify a prepared statement or to StoredProcedure (System.Data.CommandType.StoredProcedure) to specify a stored procedure.

    So, prepared -> pre-compiled -> safe parameter assignment.

    If you need more info, you may find it here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an accepted way of performing (pinch) zoom on a view that is
Is there a generally accepted way of converting a Data.Sequence (Seq a) to a
Is there a standardized (or commonly accepted way) to tackle the issue of not
Is there an easy (or generally accepted) way to load up a binary column
Is there a succinct way, or a generally accepted way to convert from a
Is there an accepted/expected best-practice way to encapsulate the model portion of ASP.NET MVC
Are there any generally-accepted coding standards (naming, casting etc) that apply specifically to iPhone/Cocoa/Objective-C?
A generally accepted way to pass all data to a view is to have
Is there any way how to get the key (or the whole entry) from
In both of the following StackOverflow questions, the accepted answer describes how to merge

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.