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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:19:22+00:00 2026-05-20T17:19:22+00:00

In log4j you could use a date pattern of %d{DDD:HHmmss} where the DDD would

  • 0

In log4j you could use a date pattern of %d{DDD:HHmmss} where the DDD would be the Day Of Year. I need to do an equivalent type of pattern in our C# app and I cannot figure out how to get this working. DataTime ToString doesn’t seem to have a formatter for Day Of Year but it does have a property for it call DateTime.DayOfYear. Anyone know how to get my date pattern set with day of year in log4net? Any advice is much appreciated.

To be clearer, I am really trying to find a log4net pattern to use in my App.Config that will format the date part of the output in the logfile. To wit in my App.Config within my appender I have:

<layout type="log4net.Layout.PatternLayout">
  <conversionPattern value="%d{MMdd-HHmmss} %-5.5p %c{1}:%L - %m%n" />
</layout>

This outputs something like:

0319-175824 INFO  Program:33 - Entering Main Method

Would like it to output:

078-175824 INFO  Program:33 - Entering Main Method
  • 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-20T17:19:23+00:00Added an answer on May 20, 2026 at 5:19 pm

    You could create your own implementation of DateTimeDateFormatter that outputs the format you require.

    FormatDate looks like the method you would want to override.

    Alternatively, you could inject a property containing DateTime.DayOfYear and reference it using the property syntax %property{doy}

    log4net.GlobalContext.Properties["doy"] = DateTime.DayOfYear;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Log4J is failing for us generally after a few hours of use in our
I use log4j 1.2.16 regarding my dependency-report. my Conversion Pattern is '%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p
I need to use log4j in my application, but I don't know how I
I use log4j for logging. And I would like to modify methods: warn(..), error(..).
I need to know how to initialise and use Log4j in java.... When i
I am getting two console warnings: log4j:WARN No appenders could be found for logger
I'm using log4j in an app I'm developing to eventually run inside Tomcat/JBoss, but
I need to append log4j content to a Swing component (JTextArea or similar). Is
I use log4j in my project and wanted to use FallbackErrorHandler for Backup-Reasons. So,
While looking through the log4j documentation I noticed that a database could be a

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.