You need to set logAppend to true

I get this message when I run “validate_lab_different_logpath”. Obviously I can update my config file and restart MongoDB etc but I don’t see where it has been stated or suggested or hinted (!) that I need to set this value for the lab beforehand, have I missed something?

Hey @dgiffin

Perhaps… :slightly_smiling_face: the subtle hint was in this section.

Note: Using db.setProfilingLevel() will not work for this lab, because this command will not persist data in the config file - if the mongod process shuts down, such as during a maintenance procedure, the profiling level set with db.setProfilingLevel() will be lost.

Which leads to finding out how to persist the logs

However just like the follow say:

If you receive an error, it should give you some idea of what went wrong.

And you figured it out!

True, but I still don’t see what log append hs to do with the profiling, if I didn’t set it profiling would still work.

Also, related, WHY doesn’t db.setProfilingLevel() press through MongoDB restarts? Intuitively it would seem that it should? Does db.setLogLevel() persist through restarts or not? How can I find out?

Like I said it was a subtle hint… maybe not very good…

The profiler is off by default. You can enable the profiler on a per-database or per-instance basis at one of several profiling levels.

So IMHO it is more reasonable to assume it will be off unless explicitly set each time started.

Im not sure. But to be certain I would include any changes from the default in the Config file

This is my config file:
dbPath: “/var/mongodb/db/”
bindIp : “,”
authorization: “enabled”
logAppend: true
This is my command to run mongod:
mongod --port 27000 --config /var/mongodb/db/config.txt --logpath /var/mongodb/db/mongod.log --fork
This is what i get running validate:

vagrant@m103:~$ validate_lab_different_logpath
You need to specify the millisecond threshold for slow operations.
I have tried setting profile levels but the error persists

Not to sure at this point. Sorry…
Perhaps this may help

I think you are missing the following from the requirements of the lab:

any query that takes 50ms or longer is logged (remember to specify this in the configuration file!)

1 Like

And as I complete my reply I see that natac13 already pointed you on how to fulfill that last requirement.

1 Like

Thanks, i did not notice that.
Instead of doing it in the config file, I used --slowms 50 directly in the command and it worked

1 Like

That’s good but I would recommend using the configuration file way of doing it. In these courses, you sometime build a configuration file from lab to lab and you need the options of the previous lab in the next lab.

I personally put my configuration under git so I can see the changes I made from lab to lab to accomplish the final result. Command line history is good but nothing beats a good commit log.


Thanks. I already put it in the config file.

Hi @natac13, @steevej-1495 - Thanks for your prompt responses, they were really helpful.

@dgiffin, db.setLogLevel() does not persist through restart.
Please get back if you have any further queries.

Curriculum Support Engineer

1 Like

Can someone help me with this.
This is the output I am getting.

Hi @Mathias_11469 it’ll be better if you create your own new thread. Your error isn’t directly related to this one.

Hi @Mathias_11469,

The error says - You need to bind the IP address.

Please follow the same steps that you followed in the Lab - Change the Default DB Path, for binding the IP addresses.

Hope it helps!

Shubham Ranjan
Curriculum Support Engineer