[ 
https://issues.apache.org/jira/browse/TS-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14662592#comment-14662592
 ] 

ASF GitHub Bot commented on TS-306:
-----------------------------------

GitHub user danobi opened a pull request:

    https://github.com/apache/trafficserver/pull/274

    TS-306 Enable log rotation for diags.log & traffic.out

    - The commit message contains an architectural overview of this feature
    - 'make test' and './traffic_server -R 1' all pass right now
    - Manual testing yields correct rotational behavior and unchanged behavior 
to access & error logs (eg. squid.log, error.log, etc)
    - Documentation is coming soon

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/danobi/trafficserver log-rotation-squashed

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/trafficserver/pull/274.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #274
    
----
commit 7be0a0d7f44505af2d2aa5e2ce85fb7e8c478a9e
Author: Daniel Xu <danie...@yahoo-inc.com>
Date:   2015-07-13T23:07:30Z

    TS-306 Enable log rotation for diags.log & traffic.out
    
    This feature provides the ability to rotate any log that
    is created by the Diags (including diags.log and
    manager.log) class, as well as traffic.out (the
    output log). These logs can be rotated either by
    time or by size, and both of these options can be
    specified in records.config [see documentation].
    While the feature is relatively small, it required
    a rather large number of internal changes. Therefore,
    the _rest_ of this commit message will be a high
    level architectural overview of the changes
    necessitated by this feature.
    
    The class, BaseLogFile, is added and it is intended
    to be an abstraction for files on disk as well as
    the stdout/stderr stream. BaseLogFile is used by
    both LogFile and Diags to help control individual
    log files. For Diags, each BaseLogFile is created by
    DiagsConfig. DiagsConfig also sets a few more values
    unavailable to Diags. LogFile uses BaseLogFile to
    manage actual files on disk. In some rare cases, LogFile
    also uses BaseLogFile to manage a stdout or stderr
    stream. Most of the functionality in BaseLogFile was
    stripped from LogFile and moved into BaseLogFile.
    
    Originally, traffic.out was just a file whose file
    descriptor was dup2()’d from traffic_cop all the way to
    traffic_server (by way of fork()/exec()). With this
    patch, traffic_cop spawns the traffic_manager process
    with the location of traffic.out specified as flags
    (—-bind_stdout and -—bind_stderr). traffic_manager
    creates two BaseLogFile objects, one for each stdout
    and stderr, both mapped to traffic.out. traffic_manager
    then spawns the traffic_server process with the same
    flags, and traffic_server creates two BaseLogFiles in
    a similar fashion.
    
    As for the actual rotation, traffic_manager checks
    to see if traffic.out needs to be rotated once per
    iteration of traffic_manager’s main loop. As soon
    as traffic_manager rotates traffic.out, SIGUSR2 is
    sent from traffic_manager to traffic_server, and
    traffic_server catches SIGUSR2 and synchronizes its
    own BaseLogFiles with the newly created
    traffic.out file on disk.
    
    For rotation of diags.log, a continuation is
    scheduled every second in traffic_server to see if
    diags.log needs rotation, and then proceeds to
    rotate if necessary. manager.log is checked for
    rotation right after traffic.out is checked for
    rotation in the main loop of traffic_manager.

----


> enable log rotation for diags.log
> ---------------------------------
>
>                 Key: TS-306
>                 URL: https://issues.apache.org/jira/browse/TS-306
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: Logging
>            Reporter: Miles Libbey
>            Assignee: Daniel Xu
>              Labels: newbie
>             Fix For: 6.1.0
>
>
> (from yahoo bug 913896)
> Original description
> by Leif Hedstrom 3 years ago at 2006-12-04 12:42
> There might be reasons why this file might get filled up, e.g. libraries used 
> by plugins producing output on STDOUT/STDERR. A few suggestions have been
> made, to somehow rotate traffic.out. One possible solution (suggested by 
> Ryan) is to use cronolog (http://cronolog.org/), which seems like a fine idea.
>               
>  
> Comment 1
>  by Joseph Rothrock  2 years ago at 2007-10-17 09:13:24
> Maybe consider rolling diags.log as well. -Feature enhancement.
>               
> Comment 2
>  by Kevin Dalley 13 months ago at 2009-03-04 15:32:18
> When traffic.out gets filled up, error.log stops filing up, even though 
> rotation is turned on. This is
> counter-intuitive.  Rotation does not control traffic.out, but a large 
> traffic.out will stop error.log from being
> written.
>               



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to