0

I am trying to set a new log destination without restarting.

It is unclear to me what to set / how to set it.

I am running

localhost > db.version()
2.6.3

I want to change the system log to

/var/log/mongod/mongod_NA.log

I have tried

localhost > db.adminCommand( { setParameter: 1, "systemLog": "/var/log/mongod/mongodb/mongod_NA.log" } )
{
    "ok" : 0,
    "errmsg" : "no option found to set, use help:true to see options "
}

localhost > db.adminCommand( { setParameter: 1, "Log": "/var/log/mongod/mongodb/mongod_NA.log" } )
{
    "ok" : 0,
    "errmsg" : "no option found to set, use help:true to see options "
}

localhost > db.adminCommand( { setParameter: 1, "logPath": "/var/log/mongod/mongodb/mongod_NA.log" } )
{
    "ok" : 0,
    "errmsg" : "no option found to set, use help:true to see options "
}

localhost > db.adminCommand( { setParameter: 1, help: true , systemLog: { 'path': '/var/log/mongod_NA.log' } } )
{
    "help" : "help for: setParameter set administrative option(s)\n{ setParameter:1, <param>:<value> }\nsupported:\n  [ ... ]",
    "lockType" : 0,
    "ok" : 1
}


1 Answer 1

0

There isn't a MongoDB admin command to change the systemLog path. This is a startup option that has to be configured at the process level (mongod or mongos) and is typically set as one of the options in a MongoDB configuration file. You will need to restart your MongoDB service or process in order to change any startup options.

However, if your goal is to use a new log file because the current one has grown too large, you should look into the logRotate command and setting up regular log rotation in your environment (for example, using logrotate on Linux).

I assume you're also aware that MongoDB 2.6 is very outdated now (this release series reached end of life in Oct 2016). There are some important stability and security fixes in subsequent releases, so at the very least you should try to upgrade to the final 2.6.12 release which is almost 2 years newer than 2.6.3. Minor releases like 2.6.x do not introduce any backward-breaking changes from earlier 2.6 releases.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .