apisix icon indicating copy to clipboard operation
apisix copied to clipboard

feat: file-log-plugin should combine with log-rotate

Open liangliang4ward opened this issue 2 years ago • 17 comments

Description

I found that file-log-plugin just write one file. I think we can combine with log-rotate(or another method) plugin to split file.

liangliang4ward avatar Mar 24 '22 08:03 liangliang4ward

They are not really related, can you give more details?

tzssangglass avatar Mar 24 '22 13:03 tzssangglass

They are not really related, can you give more details?

tzssangglass avatar Mar 24 '22 14:03 tzssangglass

I mean ,the file-log-plugin write only one file. I think the file will be very large. we should split them

liangliang4ward avatar Mar 26 '22 12:03 liangliang4ward

good idea, we should make the file logger itself support log file rotation.. cc @spacewander

tzssangglass avatar Mar 26 '22 15:03 tzssangglass

This is not easy to combine these two plugins. But we can make a try.

spacewander avatar Mar 27 '22 12:03 spacewander

This is not easy to combine these two plugins. But we can make a try.

Maybe we can make file-logger support log file rotation (without modifying the log-rotate plugin, or extracting some common functions)?

tzssangglass avatar Mar 28 '22 00:03 tzssangglass

This is not easy to combine these two plugins. But we can make a try.

Maybe we can make file-logger support log file rotation (without modifying the log-rotate plugin, or extracting some common functions)?

yes, I think it can be.

liangliang4ward avatar Mar 29 '22 01:03 liangliang4ward

i meet same problem;

AlphaChen avatar Sep 02 '22 08:09 AlphaChen

What if we support configuring the file names for both the log-rotate plugin and file-logger plugin?

tokers avatar Sep 02 '22 09:09 tokers

What if we support configuring the file names for both the log-rotate plugin and file-logger plugin?

yes we need logrotate

AlphaChen avatar Sep 02 '22 10:09 AlphaChen

I think of this a bit. What about configuring the log rotate configuration in file-logger's metadata? And let the plugin level conf refers the conf in the metadata. Therefore we can:

  1. make the file log rotate conf can be changed dynamically
  2. don't need to configure the log rotate repeatedly in each plugin level conf

CC @monkeyDluffy6017

spacewander avatar Sep 04 '22 12:09 spacewander

I just thought about your proposal, so we could get metadata from timer and roate file log in timer ? @spacewander

monkeyDluffy6017 avatar Sep 05 '22 00:09 monkeyDluffy6017

What if we support configuring the file names for both the log-rotate plugin and file-logger plugin?

yes we need logrotate

I mean, we should avoid doing duplicated things, if we can combine the two plugins and let them to work for the needs, why do we need to modify the file-logger plugin to support a supported feature?

tokers avatar Sep 05 '22 01:09 tokers

@tokers maybe it's not good idea to link the 2 plugins, it's better to make them independent ?

monkeyDluffy6017 avatar Sep 05 '22 01:09 monkeyDluffy6017

@tokers maybe it's not good idea to link the 2 plugins, it's better to make them independent ?

The combine means using them together. Of course, they should be independent.

tokers avatar Sep 05 '22 01:09 tokers

Putting the configuration into log-rotate is possible, but there are some cons so I personally don't like this idea.

Here is the limitation:

  1. the feature is meaningful only when used with other plugins like file-logger.
  2. it requires rewriting the current implementation. The current implementation uses a static conf file to configure the log rotate options and hardcodes the log file's name. The workload of modification isn't lower than modifying the file-logger.

spacewander avatar Sep 05 '22 05:09 spacewander