Rotatestrategy = None Not Working

Home » Asterisk Users » Rotatestrategy = None Not Working
Asterisk Users 4 Comments

Hello,

We have an Asterisk 11.3 server where we want log rotation handled purely by Linux’s logrotate, and not by Asterisk. To this end we’ve configured the
[general] action of /etc/asterisk/logger.conf with:

rotatestrategy = none

However, an “asterisk -rx ‘logger reload'” still rotates the log files. Does anyone know why?

Thank you in advance,

4 thoughts on - Rotatestrategy = None Not Working

  • I had to hunt, but I found an 11.17.1 system 🙂

    ‘none’ does not rotate a log file on this host. Here’s my logger.conf:

    ; Created by makefile on 2020-05-19 at 23:05:08
    ; from /source/src/obl-server/logger.conf.pre

    [general]
    rotatestrategy = none

    [logfiles]
    /tmp/ast-log-test = debug,dtmf,error,event,notice,verbose,warning

    ; (end of /etc/asterisk/obl/logger.conf)


    Thanks in advance,
    ————————————————————————-
    Steve Edwards sedwards@sedwards.com Voice: +1-760-468-3867 PST
    https://www.linkedin.com/in/steve-edwards-4244281

  • Hi Steve,

    Thanks for the answer. Since that’s what we already have configured, any idea why it wouldn’t work? As I said, when “asterisk -rx ‘logger reload'”
    is run it still rotates the log file.

  • Sorry. No clues. I always use ‘syslog’ for logging everything. I just did a quickie test to see if I could replicate the behavior.

    There’s about 600 lines of ‘diff’ between asterisk-11.3.0-rc1/main/logger.c and asterisk-11.17.1/main/logger.c.

    Maybe ‘upgrading’ to 11.17 wouldn’t be too painful if it would resolve your issue?


    Thanks in advance,
    ————————————————————————-
    Steve Edwards sedwards@sedwards.com Voice: +1-760-468-3867 PST
    https://www.linkedin.com/in/steve-edwards-4244281

  • Here’s a clue from asterisk-11.3.0-rc1/main/logger.c:

    (line 94)
    static enum rotatestrategy {
    SEQUENTIAL = 1 << 0, /* Original method - create a new file, in order */ ROTATE = 1 << 1, /* Rotate all files, such that the oldest file has the highest suffix */ TIMESTAMP = 1 << 2, /* Append the epoch timestamp onto the end of the archived file */ } rotatestrategy = SEQUENTIAL; So the default strategy is SEQUENTIAL. (line 423) if ((s = ast_variable_retrieve(cfg, "general", "rotatestrategy"))) { if (strcasecmp(s, "timestamp") == 0) { rotatestrategy = TIMESTAMP; } else if (strcasecmp(s, "rotate") == 0) { rotatestrategy = ROTATE; } else if (strcasecmp(s, "sequential") == 0) { rotatestrategy = SEQUENTIAL; } else { fprintf(stderr, "Unknown rotatestrategy: %s\n", s); } So, since 'none' is not a valid option, the default remains set. Since the code casually appears the same in 11.17.1, I'll have to backtrack on my assessment that 11.17.1 doesn't rotate without a more in depth analysis. I don't know when 'none' became a valid option, but 17.4.0 has these as the respective snippets: static enum rotatestrategy { NONE = 0, /* Do not rotate log files at all, instead rely on external mechanisms */ SEQUENTIAL = 1 << 0, /* Original method - create a new file, in order */ ROTATE = 1 << 1, /* Rotate all files, such that the oldest file has the highest suffix */ TIMESTAMP = 1 << 2, /* Append the epoch timestamp onto the end of the archived file */ } rotatestrategy = SEQUENTIAL; if ((s = ast_variable_retrieve(cfg, "general", "rotatestrategy"))) { if (strcasecmp(s, "timestamp") == 0) { rotatestrategy = TIMESTAMP; } else if (strcasecmp(s, "rotate") == 0) { rotatestrategy = ROTATE; } else if (strcasecmp(s, "sequential") == 0) { rotatestrategy = SEQUENTIAL; } else if (strcasecmp(s, "none") == 0) { rotatestrategy = NONE; } else { fprintf(stderr, "Unknown rotatestrategy: %s\n", s); } So, backport or upgrade? Also, inquiring minds want to know why the enum is in powers of 2? It's not like we can set sequential AND timestamp. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards@sedwards.com Voice: +1-760-468-3867 PST
    https://www.linkedin.com/in/steve-edwards-4244281


    Thanks in advance,
    ————————————————————————-
    Steve Edwards sedwards@sedwards.com Voice: +1-760-468-3867 PST
    https://www.linkedin.com/in/steve-edwards-4244281