Summary:ASTERISK-00262: Log files build until 2GB and Asterisk fails to run
Reporter:Brian Jones (bjones)Labels:
Date Opened:2003-09-12 16:16:59Date Closed:2011-06-07 14:04:44
Versions:Frequency of
Environment:Attachments:( 0) asterisk_logrotage.d.txt
Description:There does not appear to be any way to rotate the asterisk log file, and it continues growing until it gets too large for asterisk to read.

Request support for logrotate.
Comments:By: Brian West (bkw918) 2003-09-12 17:25:42

thats a logrotate or such other setup.  Not an issue with asterisk.  Just setup logrotate to move the logs around and or compress them in the process.


Something like that will do just fine.. now stop being lazy.

Put that in /etc/logrotate.d

edited on: 09-12-03 17:06

By: John Todd (jtodd) 2003-09-12 17:56:53

This does seem to be an issue that is external to Asterisk's featureset.  Closing.

By: Brian Jones (bjones) 2003-09-13 13:13:44

I'm not being lazy.

The problem is that asterisk is used in a large IP Centrex environment where there are always calls, and the "restart when convenient" causes busy signals on incoming PRI calls until all outgoing calls are disconnected.

If asterisk could accept a HUP signal or something telling it to recreate the log files without having to restart, that would be a big help.

By: John Todd (jtodd) 2003-09-13 13:53:10

OK, I can see the usefulness of that in the circumstance of a PRI-fed system.  Perhaps instead of  a -HUP process signal method there might be a command-line option such as "log rotate".   That would imply some changes to "logger.conf" to specify naming scheme for rotated logfiles, how many to keep, etc. in a similar manner to that of logrotate, though perhaps a much simpler set of options would be sufficient.

Then, you could run:  'asterisk -rx "log rotate" ' from a crontab or something.  To move this along, might you be able to supply some patches for such a feature?

By: Brian Jones (bjones) 2003-09-13 19:50:17

Sorry, my programming experience is pretty much limited to scripting; otherwise I would be a generous contributer to the Asterisk community. Generally, when I need progamming, I call up Mark and offer him some of my homebrew, but this time he asked me to put in a bug report regarding the size of the logfile...

I like your idea though, and I believe it would help me and others who mentioned this problem on the mailing list recently.

By: Brian West (bkw918) 2003-09-13 19:59:45

Even better * logger could be smart and recreate the files if it can't write to them. :P


By: John Todd (jtodd) 2003-09-14 15:51:11

Moved back to "new" status.

By: Brian West (bkw918) 2003-09-14 16:10:26

Now that I think about it.. why doesn't * use syslog?

By: James Golovich (jamesgolovich) 2003-09-16 23:24:13

I think using syslog would be a great idea.  Someone put a patch together a while ago for it.  It would allow

By: Brian West (bkw918) 2003-09-17 00:46:57

I think syslog would be a better option... then standard log files and rotation utils would work without the need to restart or reload *.

By: mainnerve (mainnerve) 2003-10-01 09:25:04

You guys closed out my other entry with the simple "this can be done by restarting asterisk" which my bugnotes explained was precisely the problem.  Meaning, it's not ok to solve the problem by restarting asterisk in some environments--on a PRI at least, this gives a busy to any inbound callers for the duration of the restart.  Sure, it is mitigated by doing late at night and only once per week, but that's engineering for convenience, not usefulness.  Syslog or not, it would be great if asterisk could handle logfile rotation internally or through syslog WITHOUT an interruption in service (restart when convenient).  Thanks for considering...

By: Brian West (bkw918) 2003-10-01 09:53:21

No * shouldn't do log rotation.  I don't see apache doing its own logrotation....  But it should on reload check/reopen logfiles.  Can we make that happen?

By: mainnerve (mainnerve) 2003-10-01 12:04:22

Let me try explaining the wish again.  WE DO NOT BELIEVE ASTERISK SHOULD HANDLE THE "ROTATION" INTERNALLY.  We do believe, however, that WITHOUT A RESTART, Asterisk should: when executing the subroutine that adds an event to its logs (called any time an event is generated), check to see (ioctl) if the log is missing or "new" and re-open it (and/or create it) for writing so that nothing is missed and no restart (business interruption) is required.  Does that make sense?  It should be negligible.  If the group feels this is unecessary or unimportant, the same functionality would be provided by utilizing syslog event handling instead of logfiles and therefore development hassle of making this io call is removed entirely.  I just didn't want to suggest syslog because there isnt't a "telephony.*" attribute and I hate using local6.*  ;-)

By: Brian West (bkw918) 2003-10-01 12:40:54

The most simple solution is have * recheck on "reload" or have a "reload logger" command.

By: John Todd (jtodd) 2003-10-01 13:19:17

Yeah, you're right, I suck.  I forgot about the issue where * would give busies on a PRI during reload wait time.  I'll re-open.  For the time being, while I like syslog for some things, I'd prefer to not have to get Mark to re-write the system to use syslog instead of the built-in logger.  

Additionally, I can tell you with almost 100% certainty that this patch won't be done in the near (2 months? more?) future unless someone actually supplies a patch here, as the Digium folks have quite a bit of work to do on other topics that are more pressing.  Another option would be to pay someone (Digium? someone from the -dev list?) to create such a patch.

By: Brian West (bkw918) 2003-10-01 14:32:32

I am speaking with a few people about the prospect of getting asterisk to init the logger on a reload.. or maybe add reload logger.... not sure how far we will go.

By: jjhuff (jjhuff) 2003-10-01 18:14:54

I just made a patch to add 'logger reload' to the CLI

By: Brian West (bkw918) 2003-10-01 18:51:16

logger reload works great.  Now the logrotate line could reald -rx "logger reload" instead of a restart.  w00t

By: John Todd (jtodd) 2003-10-07 02:10:28

So does the "logger reload" patch solve the problem?

By: Brian Jones (bjones) 2003-10-07 09:32:56

It does.  Excellent work.  Thanks!

By: Brian West (bkw918) 2003-10-07 09:45:19

yes sure does.