Where can I find /var/log/mongodb/mongod.log
?
I have this in configuration.nix:
{
#...
services.mongodb = {
package = pkgs.mongodb-4_2;
#bind_ip = "0.0.0.0";
enable = true;
extraConfig = ''
operationProfiling.mode: all
'';
};
}
As I understand to log all queries I should set mongod --profile=2
when running from terminal or operationProfiling.mode: all
using mongod.conf
- MongoDB logging all queries - Stack Overflow
- Configuration File Options — MongoDB Manual
- Configuration File Settings and Command-Line Options Mapping — MongoDB Manual
EDIT: I see that in nixpkgs/mongodb.nix at 573095944e7c1d58d30fc679c81af63668b54056 · NixOS/nixpkgs · GitHub
systemLog.destination: syslog
so logs should accessible with journalctl
? But I don’t see anything here:
$ sudo journalctl -f -u mongod
-- Journal begins at Tue 2021-11-09 20:09:36 CET. --
EDIT2: I have added systemLog.quiet: false
but still no logs with journalctl
:
{
#...
services.mongodb = {
package = pkgs.mongodb-4_2;
#bind_ip = "0.0.0.0";
enable = true;
extraConfig = ''
operationProfiling.mode: all
systemLog.quiet: false
'';
};
}
EDIT3:
$ mongo
> db.getProfilingStatus()
{ "was" : 2, "slowms" : 100, "sampleRate" : 1 }
EDIT4:
And this is when I don’t set operationProfiling.mode
:
> db.getProfilingStatus()
{ "was" : 0, "slowms" : 100, "sampleRate" : 1