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 6054923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:12:26+00:00 2026-05-23T08:12:26+00:00

I have looked for a fix to my issue for a few days not

  • 0

I have looked for a “fix” to my issue for a few days not and have gotten nowhere. Basically what is happening is that I have an application that writes to a database and sends an email via log4Net.

Here is where I initialize my log object:

private static readonly log4net.ILog log;
#endregion

static PTSentryService()
{
    // Initialize log4net.
    log4net.Config.XmlConfigurator.Configure();
    log = log4net.LogManager.GetLogger(typeof(PTSentryService));        
}

I then use the LogHelper class to grab the configuration information, below is what I have in my Web.Config:

<log4net>
<appender name="ADONetAppender_SqlServer" type="log4net.Appender.AdoNetAppender">
  <bufferSize value="1" />
  <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  <connectionString value="Data Source=ServerName;Initial Catalog=EventLog;Trusted_Connection=no;User ID=EventLogAdmin;Password=EVLA%dtm" />
  <commandText value="INSERT INTO EventLog ([TimeStamp],[SeverityLevel],[LoggerName],[Environment],[ApplicationName],[ApplicationPath],[ServerName],[Message],[ExceptionData]) VALUES (@TimeStamp,@SeverityLevel,@LoggerName,@Environment,@ApplicationName,@ApplicationPath,@ServerName,@Message,@ExceptionData)" />
  <parameter>
    <parameterName value="@TimeStamp" />
    <dbType value="DateTime" />
    <layout type="log4net.Layout.RawTimeStampLayout" />
  </parameter>
  <parameter>
    <parameterName value="@SeverityLevel" />
    <dbType value="String" />
    <size value="10" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%level" />
    </layout>
  </parameter>
  <parameter>
    <parameterName value="@LoggerName" />
    <dbType value="String" />
    <size value="255" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%logger" />
    </layout>
  </parameter>
  <parameter>
    <parameterName value="@Environment" />
    <dbType value="String" />
    <size value="4" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%property{EnvironmentName}" />
    </layout>
  </parameter>
  <parameter>
    <parameterName value="@ApplicationName" />
    <dbType value="String" />
    <size value="128" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%property{AppName}" />
    </layout>
  </parameter>
  <parameter>
    <parameterName value="@ApplicationPath" />
    <dbType value="String" />
    <size value="255" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%property{AppPath}" />
    </layout>
  </parameter>
  <parameter>
    <parameterName value="@ServerName" />
    <dbType value="String" />
    <size value="255" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%property{log4net:HostName}" />
    </layout>
  </parameter>
  <parameter>
    <parameterName value="@Message" />
    <dbType value="String" />
    <size value="-1" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%message" />
    </layout>
  </parameter>
  <parameter>
    <parameterName value="@ExceptionData" />
    <dbType value="String" />
    <size value="-1" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%property{exceptionDetails}" />
    </layout>
  </parameter>
</appender>

<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
  <to value="Mailbox@group.com" />
  <from value="Mailbox@group.com" />
  <subject value="(LOCL) PT Sentry" />
  <smtpHost value="group.com" />
  <bufferSize value="1" />
  <lossy value="false" />
  <threshold value="ERROR" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%utcdate [%thread] %-5level %logger [%property{log4net:HostName}] - %message%newline%newlineException details:%newline%property{exceptionDetails}" />
  </layout>
</appender>

<root>
  <level value="INFO" />
  <appender-ref ref="ADONetAppender_SqlServer" />
  <appender-ref ref="SmtpAppender" />
</root>

What occurs is that all the properties in the ILog object (isErrorEnabled, etc) are all false. I know this is due to the config not being loaded properly, but this is a copy paste job from a .Net 3.5 project that I know works. Are there changes that I need to make to accommodate 4.0?

Any info would be excellent, thanks!

  • 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-23T08:12:26+00:00Added an answer on May 23, 2026 at 8:12 am

    What you may want to do is try simplifying your config to see if it’s a certain appender or other config value that is causing this. Maybe take out your database appender and see if it works.

    Also I encountered this issue before when my references folder was jacked up. You can check the SO article out here: log4net not working in dll

    One other thing that I usually see is the logger actually being declared before the call to configure. I doubt that this matters but just throwing stuff out there.

    private static readonly log4net.ILog log = log = log4net.LogManager.GetLogger(typeof(PTSentryService));
    
    static PTSentryService()
    {
        // Initialize log4net.
        log4net.Config.XmlConfigurator.Configure();
    }
    

    Edit:

    In addition to this you may want to turn on log4net logging to see if you see anything fishy.

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

Sidebar

Related Questions

I have looked online and i havent been able to fix a problem that
i have been trying so hard to fix my issue. I've looked on google
I have looked at many other threads that show how to use accelerometer values,
I have looked but have not found a specific answer for changing just one
I have an application that prints text and images to pages on a printer.
In my application, I have two queries that occur from time to time (from
I have a little issue with AlertDialog on my application. I'm showing an AlertDialog
I have database that has multiple schemas and objects under them. I want to
So,while validating my application, I got this issue. Looked it up alot on google,
I'm having an issue removing/hiding the status bar. I have looked at other posts

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.