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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:17:56+00:00 2026-05-22T23:17:56+00:00

I’ve just taken over a C# project that uses the log4net xmllayout for logging.

  • 0

I’ve just taken over a C# project that uses the log4net xmllayout for logging.

The problem is that each event in the log has 4 data values: machinename, hostname, username and app which are always the same but are repeated for each event leading to unnecessarily large log files.

How do I prevent these from being logged?

Config file:

<?xml version="1.0"?>

<configuration>

  <!--log4net setting-->

  <configSections>

    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

  </configSections>

  <log4net>

    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">

      <file type="log4net.Util.PatternString" value="%env{LocalAppData}\\myApp\\myApp.log.xml" />

      <appendToFile value="true" />

      <rollingStyle value="Size" />

      <maxSizeRollBackups value="1" />

      <maximumFileSize value="3MB" />

      <staticLogFileName value="true" />

      <layout type="log4net.Layout.XmlLayoutSchemaLog4j">

      </layout>

    </appender>

    <root>

      <level value="DEBUG" />

      <appender-ref ref="RollingFileAppender" />

    </root>

  </log4net>



  <system.serviceModel>

    <bindings>

      <basicHttpBinding>

        <binding name="BasicHttpBinding_myAppWCF" closeTimeout="00:01:00"

          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

          useDefaultWebProxy="true">

          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

            maxBytesPerRead="4096" maxNameTableCharCount="16384" />

          <security mode="None">

            <transport clientCredentialType="None" proxyCredentialType="None"

              realm="">

              <extendedProtectionPolicy policyEnforcement="Never" />

            </transport>

            <message clientCredentialType="UserName" algorithmSuite="Default" />

          </security>

        </binding>

      </basicHttpBinding>

    </bindings>

    <client>

      <endpoint address="http://localhost:12372/conserv" binding="basicHttpBinding"

        bindingConfiguration="BasicHttpBinding_myAppWCF" contract="myAppNOWServiceClient.myAppWCF"

        name="BasicHttpBinding_myAppWCF" />

    </client>

  </system.serviceModel>

  <startup>

    <supportedRuntime version="v2.0.50727"/>

  </startup>

</configuration>
  • 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-22T23:17:57+00:00Added an answer on May 22, 2026 at 11:17 pm

    When you use XMLLayout, you get what they want to give you. You can’t specify which items to log like you can with the other layouts. However, there are alternatives if you want to change this functionality. First, you can change to a file appender and try to make a layout manually. That gets messy at best. The other option is to create your own appender that logs to the XML file only what you want and in the schema you want. This is much more desirable if you are doing a long-term change unless you really don’t want to add to log4net.

    If you want to go the second route, here is an article that will show you exactly how to do so:

    http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/making-an-xmllayout-for-log4net

    Here is a SO question that has an answer that explains how to do this as well:

    Log4net xml output

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I have a French site that I want to parse, but am running into

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.