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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:14:41+00:00 2026-06-10T15:14:41+00:00

I still dont really get it how to change log4net if I would like

  • 0

I still dont really get it how to change log4net if I would like to have every x hour a log. I have this:

      <log4net>
        <root>
          <level value="DEBUG"/>
          <appender-ref ref="LogFileAppender"/>
        </root>
        <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
          <param name="File" value="C:\log.txt"/>
          <param name="AppendToFile" value="true"/>
          <rollingStyle value="Size"/>
          <maxSizeRollBackups value="10"/>
          <maximumFileSize value="100MB"/>
          <staticLogFileName value="true"/>
          <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} – %m%n"/>
          </layout>
        </appender>
  </log4net>

I have one log and Im adding the logs always in this one log.txt – now I would like to have lets say for every day a new log file (24hours) or maybe for every 12hours a new log. What do I have to change in my config? Any suggestions to my config? Thank you

  • 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-06-10T15:14:43+00:00Added an answer on June 10, 2026 at 3:14 pm

    RE: http://logging.apache.org/log4net/release/config-examples.html

    This example shows how to configure the RollingFileAppender to roll log files on a date period. This example will roll the log file every minute! To change the rolling period adjust the DatePattern value. For example, a date pattern of “yyyyMMdd” will roll every day. See System.Globalization.DateTimeFormatInfo for a list of available patterns.

    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="logfile" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <datePattern value="yyyyMMdd-HHmm" />
    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
    

    In your particular case, the above example with <datePattern value="yyyyMMdd-HH" /> would only allow you to log every hour.

    However, if you wanted to log every X hour, you could create a custom appender derived from RollingFileAppender and override the AdjustFileBeforeAppend method that would check the current time against your next scheduled log interval date. See Have a Log4Net RollingFileAppender set to roll weekly for example.

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

Sidebar

Related Questions

I already read this question about socket synchronization but I still dont get it
Really hoping to get this finished up, and sadly I don't have enough experience
I've been working a lot lately with perl, still I dont really know how
I still dont get it, which color will be paragraph test1 and why? <style>
I have some code (which I cannot change) that I need to get working
I have a pile of batch files that do something like this with program
I've read several questions here concerning Tomcat and logging but I still really don't
I'm a complete noob in java. I still really don't know how to code.
Something I still don't understand when performing an http-get request to the server is
It seems I still don't get generics ... I want a general function to

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.