Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug to logging by day of week #2089

Closed
RussianDragon opened this issue May 3, 2017 · 10 comments
Closed

Fixed bug to logging by day of week #2089

RussianDragon opened this issue May 3, 2017 · 10 comments
Labels
bug Bug report / Bug fix file-target
Milestone

Comments

@RussianDragon
Copy link

Hi!
We found bug in logging by day of week.
If you set option "archiveEvery" as any day of week, nlog will create new archive file every day.

Мы нашли ошибку в создании файлов логов-архивов, если установлено архивирование по дням недели. Файлы создаются каждый день, а не в определенные дни


next code сontains fix bug

private static DateTime TruncateArchiveTime(DateTime input, FileArchivePeriod resolution)
        {
            switch (resolution)
            {
                case FileArchivePeriod.Year:
                    return new DateTime(input.Year, 1, 1, 0, 0, 0, 0, input.Kind);
                case FileArchivePeriod.Month:
                    return new DateTime(input.Year, input.Month, 1, 0, 0, 0, input.Kind);
                case FileArchivePeriod.Day:
                    return input.Date;
                case FileArchivePeriod.Hour:
                    return input.AddTicks(-(input.Ticks % TimeSpan.TicksPerHour));
                case FileArchivePeriod.Minute:
                    return input.AddTicks(-(input.Ticks % TimeSpan.TicksPerMinute));
                case FileArchivePeriod.Sunday:
                    return CalculateNextWeekday(input.Date, DayOfWeek.Sunday);
                case FileArchivePeriod.Monday:
                    return CalculateNextWeekday(input.Date, DayOfWeek.Monday);
                case FileArchivePeriod.Tuesday:
                    return CalculateNextWeekday(input.Date, DayOfWeek.Tuesday);
                case FileArchivePeriod.Wednesday:
                    return CalculateNextWeekday(input.Date, DayOfWeek.Wednesday);
                case FileArchivePeriod.Thursday:
                    return CalculateNextWeekday(input.Date, DayOfWeek.Thursday);
                case FileArchivePeriod.Friday:
                    return CalculateNextWeekday(input.Date, DayOfWeek.Friday);
                case FileArchivePeriod.Saturday:
                    return CalculateNextWeekday(input.Date, DayOfWeek.Saturday);
                default:
                    return input;   // Unknown time-resolution-truncate, leave unchanged
            }
        }
@304NotModified
Copy link
Member

Hi, please use the issue template

@RussianDragon
Copy link
Author

We writing about of bug, and writing fix code.
What's not clear?

Мы написали об ошибке и написали как исправить.
Что тут непонятного?

@304NotModified
Copy link
Member

which NLog version? is this NLog 4.4.8? NLog 5 beta?

@RussianDragon
Copy link
Author

RussianDragon commented May 4, 2017

It is master branch.
Commit 3954157

@snakefoot
Copy link
Contributor

@RussianDragon Sounds like you are very close to make a unit-test and a github pull-request :). This will increase the chance of it making it into next NLog-release.

@RussianDragon
Copy link
Author

I have not enough permissions to push my fix-branch...
image

@304NotModified
Copy link
Member

304NotModified commented May 4, 2017

Steps:

Create a fork (the button in github)
Add it as remote (or clone and copy changes)
Push
Create PR in github

@RussianDragon
Copy link
Author

RussianDragon commented May 5, 2017

@304NotModified Thank you. :)
I created new pull requests.

@304NotModified
Copy link
Member

You fixed it!
(in #2093)

thanks!

@304NotModified
Copy link
Member

NLog 4.4.9 is in the deploy pipeline! Will be online in an hour!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report / Bug fix file-target
Projects
None yet
Development

No branches or pull requests

3 participants