memcached log file

10,128 views
Skip to first unread message

rwthomas

unread,
May 6, 2009, 12:25:13 PM5/6/09
to memcached
We recently updated to memcached 1.2.8. with the previous version, I
was log to a file of my choice by adding to the startup file. 1.2.8
does not seem to have the same ability. I need to send the output of
memcached to a file other than stdout. Is there a way to do this? If
not, can this be added in future versions?

Trond Norbye

unread,
May 6, 2009, 1:31:08 PM5/6/09
to memc...@googlegroups.com


Why can't you just redirect the output from the memcached server into
a file?

./memcached -vvv > /var/log/memcached.log 2>&1

?

Cheers

Trond

rwthomas

unread,
May 6, 2009, 1:57:45 PM5/6/09
to memcached
We use it as a service ie: service memcached start. When we run it
like this, I haven't been able to redirect the output like you say.
if there is a way to do it with that command, I would love to know.

Brett Hoerner

unread,
May 6, 2009, 2:06:51 PM5/6/09
to memc...@googlegroups.com
At the end of the day "service" runs a script of some kind. I'm not
sure what OS you're talking about, but I'm sure there is an init file
or something like SMF that you can edit, and that's where you want to
change it to redirect the output.

Brett

rwthomas

unread,
May 6, 2009, 2:43:15 PM5/6/09
to memcached
Yes, I understand that a service runs a script. With memcached 1.2.2,
you could specify the logfile in the startup script (memcached-start)
in the /usr/local/bin dir. The new version of memcached does not use
memcached-start. I have tried to add redirects to the start script,
but the only thing it puts in the file that I am redirecting to is the
OK that comes when you start or stop the service. the memcached-start
file is actually a perl script. Below is an example of what we used
to run:
#my $fd_reopened = "/dev/null";
my $fd_reopened = "/root/mem.log";
sub handle_logfile {
# my ($logfile) = @_;
my ($logfile) = "/root/mem.log";
$fd_reopened = $logfile;
}
sub reopen_logfile {
# my ($logfile) = @_;
my ($logfile) = "/root/mem.log";
open *STDERR, ">>$logfile";
open *STDOUT, ">>$logfile";
# open *STDIN, ">>/dev/null";
open *STDIN, ">>$logfile";
$fd_reopened = $logfile;

as you can see, we redirected to mem.log. When we upgraded, we found
that memcached 1.2.8 does not use the memcached-start perl script.
that is why I am trying to find a way to do this again.
We are running CentOs 5.2 with memcached 1.2.8

Thanks for your help

On May 6, 12:06 pm, Brett Hoerner <bretthoer...@gmail.com> wrote:
> At the end of the day "service" runs a script of some kind.  I'm not
> sure what OS you're talking about, but I'm sure there is an init file
> or something like SMF that you can edit, and that's where you want to
> change it to redirect the output.
>
> Brett
>

Les Mikesell

unread,
May 6, 2009, 4:16:33 PM5/6/09
to memc...@googlegroups.com

Centos inherits the RedHat style init scripts which typically use the
daemon() function in /etc/rc.d/init.d/functions to start programs - and
it redirects stdout and stderr to /dev/null among other things. You'll
probably have to make the /etc/init.d/memcached script do the same
things directly instead of using daemon() so you can control the
redirection yourself. It would be a little handier for this style of
control if memcached had a command line option like '-o logfile' so it
could be controlled in the options the script sources from
/etc/sysconfig/memcached and expands on the command line.

--
Les Mikesell
lesmi...@gmail.com

Reply all
Reply to author
Forward
0 new messages