M103 Chapter 1 - Lab: Logging to a Different Facility

Use a configuration file to store log files in a new location:

  1. Update your configuration file such that:
  • mongod sends logs to /var/mongodb/logs/mongod.log
  • mongod is forked and run as a daemon (this will not work without specifying logpath)

As per the above instructions I have added the following lines to mongod.conf file
systemLog:
path: “/var/mongodb/logs/mongod.log”
destination: “file”

Then run the mongod command with the conf file and then Run Test
mongod -f mongod.conf

2 total, 0 passed, 0 skipped:
[FAIL] “Mongod was started with the new logpath”

Did you launch mongod with the logpath /var/mongodb/logs/mongod.log?

[FAIL] “Mongod process was forked”
Did you modify your mongod configuration to fork the process?


Also run the CreateUser command. Which has created the user.
mongo admin --host localhost:27000 --eval ’
db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

Upon clicking the Run Test gives the following output

2 total, 1 passed, 0 skipped:
[PASS] “Mongod was started with the new logpath”
[FAIL] “Mongod process was forked”

Did you modify your mongod configuration to fork the process?

As per Lab instructions I had added the following lines to mongod.conf
processManagement:
fork: true

Why there is fork related error?

Hi there,

Can you include a screen shot of the config file?

Hi there,

Thanks for your interest in resolving my issue.

As advised, I am here sending you the screenshot of conf file.

Regards,
MahanteshM103-Chapter-1 - Lab-Logging-to-a-Different-Facility - Screenshot

It looks fine to me.

My hypothesis fork was added after lauching mongod.

If this sounds possible, run

killall mongod && mongod -f mongod.config

Or just run separate if this doesn’t work.


When you restart, something like this should show up:

mongod -f mongod.conf           
about to fork child process, ...
forked process: 336
child process started successfully

The configuration file you posted does not show the processManagement: configuration.

Hi there,

I tried to follow as you instructed, but it didn’t work. Please find an attachment for the screenshot showing the conf file and command execution output.

Regards,
Mahantesh

You got No such file or directory because you used mongod.config while the file browser, the file editor and the lab description indicate that it is mongod.conf.

1 Like

Hi @Mahantesh_Angadi,

This :point_down:

Let us know if you are still facing any issue.

~ Shubham