-
Notifications
You must be signed in to change notification settings - Fork 191
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
allow several matches for one log file, most specific wins #38
Comments
Hi, I would like to take on this feature and implement it. I will define the following functions:
For example, the following 2 configs:
They makes 2 pattern groups:
Any comments would be appreciated. |
I do not think we can (or want to) define strict order on these patterns. How would you compare |
No, I didn't have the intention to do so. In your example, I will treat it as duplicate configs, just like before. |
More specifically, I will define
|
It might be simpler to evaluate the patterns in order, and ignore files which have already been rotated. Thus the original example:
So the above would rotate
to be put in |
I like @wyohm's idea. |
Yes, it sounds reasonable. Sorry for the delay! |
@kdudka I will start working on it. Do you think I should add an option (e.g. |
I submitted my draft pull request. Please tell me if the patch needs modified (coding style, unit tests, ...), thanks. |
Could this be a directive so that it only applies to the current config file? |
@johnlinp Thank you for working on it! I agree with @wyohm that a configuration directive would be better as it would be consistent with how |
Great, thanks. However, you may want to rethink the name of the directive. I believe May I suggest |
|
I am not an English native speaker, so I am not sure if this is correct. I think So I propose |
It depends on what you're considering duplicated: the log file, or the rule. The error message: |
@kdudka What do you say? |
What about |
|
Or simply |
Yes, |
OK, I'll use |
I had my second version pushed. Please give me some comments. An example with |
What should we do with As it works now, each configuration section is associated with a set of globs and the actual set of files produced by expansion of the globs. If a prerotate/postrotate script runs with If we only update the set of files and keep the original set of globs while overriding a previous configuration, some files might be processed by multiple prerotate/postrotate scripts when Would it make sense to pass line-separated list of files (instead of globs) to prerotate/postrotate scripts when both |
This issue seems to have gotten left by the wayside, are there still plans in the works to implement this? |
While analyzing all the consequences of the proposed extension, it turned out that it is more difficult to implement it properly than it had originally seemed to. Obviously, logrotate has been evolving for a long time without keeping such extensions in mind. Some decisions incompatible with this proposal have been made in the past (the |
That's too bad, @kdudka. This would be such an improvement. Has anyone considered addressing this problem from a different perspective? E.g. by switching to /bin/bash (or adding optional support for it) with extglob option on, it would be possible to exclude certain patterns by just writing a glob. E.g. I've scoured the Internet in an attempt to find an elegant way to exclude files like suggested by this extglob example but eventually ended up here only to learn that the effort to address this issue was abandoned. Meanwhile, Stack Overflow and other places suggest ugly hacks that some people do use. For example:
Which may work in some scenarios but not with patterns as in the example of the topic starter. |
This is really crazy. After 6 years, there's got to be a straight-forward solution here. Can we have a discussion forum in which the high level functioning is completely described, and in another thread or page, summarize the desired behavior? It seems to me that @kdudka has mentioned the specific behavior, but it's not easy to find in these issue threads. There have been several good points made here by many. A recent pull request ("strong") is a very good idea except for the name of the option. It also certainly is a much needed band-aid, but might its implementation come into conflict with the "right" way to do things and to other needs? My question is this: why is it even a fatal error when a log entry is matched multiple times?? Was this always the case for 20 years? What would happen if it simply stops being an error, but a warning instead? If it stops being an error, how would the current code handle it? Would it override it with the last one to match? If so, simply document that behavior and be done with it. Someone mentioned that such behavior could be a problem for environments that tend to use things like ".local" file-naming conventions for configuration. I don't see how ignoring the duplicity could be a problem here. If that change I suggest later proves to be a problem, then you add a global switch which has several flavors:
Do NOT let this progress be obstructed by difficult questions such as shared-script handling-with-inheritance / glob-override. Flip a coin and decide how it will go. In the future, scripts should be named with their own blocks indepdenent of fileglobs, and then fileglob-blocks should refer to the scripts by name. But really, we're getting ahead of ourselves. |
The previous comment refers to pull request #473, which might be the ultimate solution for use cases like this. While it is not what this issue originally asked for, the proposed solution can be implemented in a reasonable time frame and without breaking backward compatibility. |
i think that since the 1st post of @CoolCold , the thread could have gone way more simple.
what confused me, and make me realised the above the hard way, was that part of man page:
while that is true about options is exactly the oposite for current logic handling the log target definition. I use: Debian 11 / logrotate 3.18.0-2+deb11u1 |
@gkapad Thanks for feedback! Unfortunately, I do not understand what exactly is confusing in the man page. Could you please open a merge request with the proposed changes of the documentation? |
Note that the |
Cant check 3.21, but see for example, in my debian's version ( 3.18.0-2),
Describing the configuration file, still here: https://github.com/logrotate/logrotate/blob/master/logrotate.8.in#L130 , says
All i want to say is: |
If I remember correctly, the problem was not with a warning/error being printed. The main problem was that, without |
I think the above statement actually means this:
|
I have stumbled upon this GitHub issue as I was recently hit by this same logrotate issue. I have a custom logrotate file, which is a collection of files specific to my system. So, instead of fixing the duplicates, what I do is to setup a cron job using my "custom" file as the parameter. This seems to work for now. |
I'd be nice to allow (and not produce error message) in case of several matches for log. For example, i have /var/log/nginx/ dir, where every nginx log is going. Some specific logs, which are used for statistics collection (machine parsable format, for example), can be rotated everyday, and kept for 1 day only. But if i produce two entires, like:
and
i got the error on stderr (but exit code is 0) about duplication.
Most specific file match (pattern length which matched?) should win and do not produce errors.
The text was updated successfully, but these errors were encountered: