Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Log4net: one loggfile a day

Log4net: one loggfile a day

Scheduled Pinned Locked Moved C#
helpquestiontutorialworkspace
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stephan_007
    wrote on last edited by
    #1

    Hy everyone! I do need your help. I would like to create a logfile for my application one a day (eg. Logfile_20090210.log for today, Logfile_20090211.log for tomorrow etc.). the log4net config file looks like this

    <configuration>
    <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
    </configSections>
    <log4net>
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
    <param name="File" value="C:\\PrintService.log" />
    <param name="AppendToFile" value="true" />
    <param name="rollingStyle" value="Date" />
    <param name="datePattern" value="yyyyMMdd" />
    <layout type="log4net.Layout.PatternLayout">
    <!-- <param name="Header" value="[Header]\r\n" />
    <param name="Footer" value="[Footer]\r\n" /> -->
    <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
    </layout>
    </appender>
    <root>
    <!-- <level value="INFO" /> -->
    <appender-ref ref="RollingLogFileAppender" />
    </root>
    </log4net>
    </configuration>

    I do have two problems: there is no logfile with the config above. when I change this to "yyyyMMdd-HHmm" for datePattern, then it works, but I do not want the time to be part of the logfilename. the second problem is the logfile is named PrintServce.log20090210-1346 for example. So my question: What does the config have to look like to get PrintServer_20090210.log for example? I found pages with configs similar like mine ("yyyyMMdd" for datePattern). But none worked! Thanks for any help! Stephan.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups