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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:40:48+00:00 2026-05-11T08:40:48+00:00

I am using Log4net for a while now and it’s an amazing logging framework,

  • 0

I am using Log4net for a while now and it’s an amazing logging framework, especially when hooked into Castle.Windsor. However…

I usually use the rolling file appender, but this has resulted in too many log files than I actually want, so instead, for my latest project, have used the basic LogFileAppender instead, but the problem is the log file keeps growing (seemingly forever).

How can I tell the appender to not go over a fixed size (and start removing old logs and appending the new ones to the file?

My current configuration looks like:

<appender name='LogFileAppender' type='log4net.Appender.FileAppender'>   <file value='E:\Logs\iWater\Schedule-Dispatch-API.log'/>   <param name='AppendToFile' value='true'/>   <maximumFileSize value='2048KB'/>   <layout type='log4net.Layout.PatternLayout'>     <conversionPattern value='%-16date{dd MMM HH:mm:ss} %-7level %-25.35logger{1} %message%newline'/>   </layout> </appender> 

Its seems like the maximumFileSize attribute is not being respected. Any solutions?

Alternatively, how can I configure the rolling file appender to only create 1 file (ever)?

  • 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. 2026-05-11T08:40:49+00:00Added an answer on May 11, 2026 at 8:40 am

    The FileAppender class does not have the MaxFileSize/MaximumFileSize properties. You only get those if you use a RollingFileAppender. Here’s an example that will limit your file to a fixed maximum size, with no backups (set maxSizeRollBackups to 0). Note that when the file reaches its max size, it truncates (basically deletes all existing logging and starts over):

    <appender name='RollingFileAppender' type='log4net.Appender.RollingFileAppender'>     <file value='log.txt' />     <appendToFile value='true' />     <rollingStyle value='Size' />     <maxSizeRollBackups value='0' />     <maximumFileSize value='10MB' />     <staticLogFileName value='true' />     <layout type='log4net.Layout.PatternLayout'>         <conversionPattern value='%date [%thread] %-5level %logger [%property{NDC}] - %message%newline' />     </layout> </appender> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You want to add an Exit Sub to your routine:… May 11, 2026 at 11:30 pm
  • Editorial Team
    Editorial Team added an answer Oops, found the solution. If you have access to glib,… May 11, 2026 at 11:30 pm
  • Editorial Team
    Editorial Team added an answer You can try the specification pattern for this. It's a… May 11, 2026 at 11:30 pm

Related Questions

I am using Log4net for a while now and it's an amazing logging framework,
Background I am writing a class library assembly in C# .NET 3.5 which is
I am using log4net 1.2.10.0. I have extended ILog and LogManager to include a
I decided to use log4net as a logger for a new webservice project. Everything
I am using log4net and I was to save the log file in the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.