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

  • Home
  • SEARCH
  • 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 70447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:43:56+00:00 2026-05-10T19:43:56+00:00

Have Log4Net configured in our application to use a date stamped name and a

  • 0

Have Log4Net configured in our application to use a date stamped name and a 10Meg file size limit.
This automatically causes a rollover to a new file at midnight and whenever the 10Meg limit is reached. I would also like to roll over the logging to a new file each time the application is started (or closed).
Can I get all three roll over behaviours?

  • 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-10T19:43:57+00:00Added an answer on May 10, 2026 at 7:43 pm

    Set appendToFile to false in your config file.

    <appender name='RollingLogFileAppender' type='log4net.Appender.RollingFileAppender'> ....   <appendToFile value='false' /> .... </appender> 

    EDIT: To answer Craig’s comment:

    If you properly setup StaticLogFileName and CountDirection (see http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.html for more), then things roll as desired. We programmatically configure the logger in our app where we use this, but this is what the code looks like:

    Dim Layout As New PatternLayout('%date{yyyy-MM-dd HH:mm:ss,fff} [%-6thread] %-5level %type{2}.%method(%line) - %message%newline')  Dim Appender As New log4net.Appender.RollingFileAppender() Appender.File = Path.Combine(FileSystemHelper.LogDirectory, LogFileName) Appender.Layout = Layout Appender.AppendToFile = False ' we will start a new one when the program starts' Appender.Name = 'RollingLogFileAppender' Appender.Threshold = LogLevel() 'May want to set this by configuration' Appender.RollingStyle = log4net.Appender.RollingFileAppender.RollingMode.Size 'This means it will start a new log file each time the log grows to 10Mb' Appender.MaximumFileSize = '10MB' Appender.MaxSizeRollBackups = -1 'keep an infinite number of logs' Appender.StaticLogFileName = True Appender.CountDirection = 1 ' to reduce rollover costs' log4net.Config.BasicConfigurator.Configure(Appender) Appender.ActivateOptions() 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 52k
  • Answers 52k
  • 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
  • added an answer The sizes of int etc in C/C++ aren't formally defined… May 11, 2026 at 6:41 am
  • added an answer This page describes how to and lists some plugins that… May 11, 2026 at 6:41 am
  • added an answer Alexander Werner has a 'System Hotkey Component' project over at… May 11, 2026 at 6:41 am

Top Members

Trending Tags

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

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.