Filename in log4net - Programmers Heaven

Howdy, Stranger!

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


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?


  • 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: 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, 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:
    '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")

    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.