-
Notifications
You must be signed in to change notification settings - Fork 776
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
dateFile appender "daysToKeep" not working #836
Comments
|
@Shinapp could you post your log4js config, please? Something that might be the cause is that log4js only checks the date/time when you write something - so you have to log something after you change the date on your system, or nothing will happen. |
@nomiddlename Yes, I have logged something. { log4js.configure('./config/log.config') |
We made some fixes to date file rotation in 4.2.0, could you try again and see if it fixed your problem? |
The problem still persist. I am using log4js@4.3.0 . |
I have the same problem. Windows 7 |
Hey @Shinapp - are you still having this problem? Are you on windows too? I'm just trying to work out what may be the cause, date file rotation seems to work fine on my mac and for other people. |
I still have the problem. I tried the code on mac, linux and window. The condition is always false and the cleaning mechanism is not triggered. |
Possibly related to #909 |
There were a lot of fixes for file rotation in log4js 5.x - please give log4js@5.1.0 a try and let me know if the problem still exists. |
Thank you for your reply but seems the problem still exists. Thank you. ├─┬ log4js@5.1.0 |
@Shinapp agree with you. the issue still exists in log4js@5.1.0 |
@Shinapp I think your problem is related to the pattern you're using: "yyyyMMdd" maps to all digits, which the code thinks is a file index instead of a date. As a workaround, or to test this out, try using "yyyy-MM-dd" as the pattern. I should have a fix for this issue in the next few days. @mariuswang007 I'm not sure that your issue is the same, if changing that line fixed it. Could you post your log4js config, please? |
Tried but fail. I have created lots of log file named "filename,log.2019-10-17" etc. |
this.options.numToKeep <-- this is related to the config daysToKeep exist |
@Shinapp could you post some step-by-step instructions on how you're testing this, please? I'm having trouble reproducing the issue. Ideally, if you could include the code you're using as well, that would be great. |
Repeat 2-5 Suppose whenever a new log file generated will trigger the housekeeping. |
With alwaysIncludePattern set, it will always create a new file if the date is different - but that won't trigger clean up of the old ones until the day changes. Does that describe what you're seeing? New log file created, but the old ones stay there? |
Yes, "New log file created, but the old ones stay there", but I expect the old ones clean up after the day passes the larger than daysToKeep. |
It won't clean up old files on startup, only when the day changes if it is running. Maybe try changing the date without killing the script, to see if that does what you expect it to do? |
Seems the problem is solved. I am currently using log4js@5.2.1 |
This is really the situation I facing. I tried to run on an express services and get the expected behaviour you mentioned. However, when I running a small script that has no date change during the script running (on cron), it does not clean up old files on startup (or termination) Is there a way to improve my script or it is a feature request? P.S. I am running cron jobs and I hope log files will be clean up everyday. |
I think the behaviour you describe would be easier to do by adding the clean up to your cron job script. I'm going to close this issue. |
#806
Problem seems still exists fir log4js 4.0.2
I have changed local time to test:
├─┬ log4js@4.0.2
│ ├── date-format@2.0.0
│ ├─┬ debug@3.2.6
│ │ └── ms@2.1.1
│ ├── flatted@2.0.0
│ ├── rfdc@1.1.2
│ └─┬ streamroller@1.0.1
│ ├── async@2.6.1 deduped
│ ├── date-format@2.0.0 deduped
│ ├── debug@3.2.6 deduped
│ ├── fs-extra@7.0.1 deduped
│ └── lodash@4.17.11 deduped
node v11.5.0
The text was updated successfully, but these errors were encountered: