Bug 66253 - rotatelogs -n option log file suffix can't modify
Summary: rotatelogs -n option log file suffix can't modify
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: support (show other bugs)
Version: 2.5-HEAD
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-06 12:41 UTC by max
Modified: 2022-09-06 13:28 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description max 2022-09-06 12:41:00 UTC
some log system only collect *.log

and rotatelogs with option -n will gen file log.1 log.2

can't be collect by log system

so rotatelogs need an option to make log file suffix fixed
Comment 1 Eric Covener 2022-09-06 12:44:15 UTC
-n is meant for circular set of files that overwrites itself, like short-term trace. maybe it's not a good fit if you expect it to be collected.  

Not using -n  means you can choose whatever filename you like.

what's drawing you to -n in this case?
Comment 2 max 2022-09-06 12:47:21 UTC
i want save log with 50M per file, and two file for rotate. total 100m space

is there a good method to gen log file  xx.1.log xx.2.log or xx.2022-xxx(date).log
Comment 3 Eric Covener 2022-09-06 12:49:44 UTC
The examples here show how to use a format string in the filename argument, you can tack ".log" onto the end. Of course your 2nd arg will be "50M".
Comment 4 Eric Covener 2022-09-06 12:55:10 UTC
Whoops, never pasted: https://httpd.apache.org/docs/2.4/programs/rotatelogs.html
Comment 5 max 2022-09-06 13:07:41 UTC
while true; do echo 123; done | rotatelogs -n2 1.%Y-%m-%d-%H_%M_%S.log 1k 
Cannot use -n with % in filename


if not append -n2, it will gen many log file

how to make a limit of number of file
Comment 6 Eric Covener 2022-09-06 13:19:58 UTC
(In reply to max from comment #5)
> while true; do echo 123; done | rotatelogs -n2 1.%Y-%m-%d-%H_%M_%S.log 1k 
> Cannot use -n with % in filename
> 
> 
> if not append -n2, it will gen many log file
> 
> how to make a limit of number of file

you can't do both at the same time with rotatelogs directly.

With -n, you could add a hard link to each file with a simple -p script:

```
#!/bin/bash

CURFILE=$1
PREVFILE=$2

ln -f $CURFILE ${CURFILE}.log
```

Or without -n, use something like logrotated to purge old log files.
Comment 7 max 2022-09-06 13:28:48 UTC
so it is too bother

so i think it can add option to control log file suffix when with -n option

can save log file with x.1.log x.2.log


thanks