Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Filename in log4net

dnsldnsl Posts: 2Member

Hi All,
i am doing a VB.NET windows application. In that i am using Log4Net for logging details. I am new to using Log4Net. The problem i am facing is i want to create the logfiles with same name each day. means today if a log file is created with name debug.log, tomorrow also it should create a new log file with same name with out any change in the previous file name. how can i do this ? My appender configuration looks like this ..











































How can i do this ?? do i need to make any change in the appender config ? can anybody help?

Comments

  • seancampbellseancampbell Pennsylvania, USAPosts: 684Member ✭✭✭
    I don't know anything about the software you are using... I did how ever read a few things just now and here is a suggestion (don't know if this will help or not)...

    Based on what I read (here: http://logging.apache.org/log4net/release/config-examples.html) you should be able to specify Environment Variables in the filename of the Log File... There is NO WAY to have 2 files with the SAME NAME in the SAME LOCATION, so if you want to have a new file each day, you have to create a file with a new name... Based on what I read on Logging.apache.org, you should be able to specify a dynamic filename, but how this acts I couldn't tell you since I have never used this before...

    here goes:
    [code]
    'First you want to set the Enviroment Variable when you load your software
    System.Environment.SetEnvironmentVariable("log4netFile", "log-" & Format(Now.ToString, "MM-dd-yyyy") & ".txt")
    [code]

    Now that your environment var is set, you can use that $(log4netFile) environment variable in the FileName of the log4net settings in app.config.

    Hope this atleast gets you moving down a path towards solving your question
  • DanManDanMan Posts: 1Member
    I know its a pretty dead thread... but I suspect the issue is from using
    when you want to be using



Sign In or Register to comment.