logging all commands / queries

610 views
Skip to first unread message

François Vatel

unread,
Oct 16, 2014, 9:09:13 AM10/16/14
to reacti...@googlegroups.com
Hello!

Is it possible to log all commands sent to mongo? I want to collect some simple stats (how many "find" commands etc)?
I was trying to set TRACE level but the only thing I see (related to mongo) is:

... | DEBUG | reactivemongo.core.actors.MongoDBSystem MyActorSystem-akka.actor.default-dispatcher-6 - started (reactivemongo.core.actors.MongoDBSystem@6eaf100d)

My logback.xml looks like this:

<configuration scan="true" debug="false">
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>logs/my.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>logs/my.log.%d{yyyy-MM-dd}</fileNamePattern>
      <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder>
      <pattern>%d{dd/MM/yyyy HH:mm:ss, UTC} UTC | %-5level | %logger{50} %X{sourceThread} - %msg%n</pattern>
    </encoder>
  </appender>
  
    <logger name="akka" level="DEBUG" />
  <logger name="reactivemongo" level="TRACE"/>

  <root level="TRACE">
      <appender-ref ref="FILE" />
  </root>

</configuration>

I also tried withou logback.xml at all (logging to console), no success. In general, TRACE level is working in my app (I see some logs), but not for RM.

François Vatel

unread,
Oct 16, 2014, 9:11:28 AM10/16/14
to reacti...@googlegroups.com
I use 0.10.0 with Scala 2.10.4, akka 2.2.4

Reid Spencer

unread,
Oct 16, 2014, 10:24:48 AM10/16/14
to reacti...@googlegroups.com
François,

MongoDB has an audit function that will likely do what you want. Doing this at the driver (i.e. reactivemongo) level is probably not going to be sufficient as it doesn’t include operations that occur outside of the driver. I suggest you read this page:

Hope that helps,

Reid



--
You received this message because you are subscribed to the Google Groups "ReactiveMongo - http://reactivemongo.org" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reactivemong...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reid Spencer

unread,
Oct 16, 2014, 10:27:52 AM10/16/14
to reacti...@googlegroups.com
I should also probably mention the mongostat program which might just give you the simple statistics that you’re looking for. 

François Vatel

unread,
Oct 17, 2014, 2:44:25 AM10/17/14
to reacti...@googlegroups.com
Reid, thanks for mongostat & audit links! Seems they can help.

Still wonder... should I do something special to enable debug/trace logging in ReactiveMongo? Sometimes for simple tasks it's easy to use logs and just grep them. Or add more logging in the code - instead of investigating complex tools.
Reply all
Reply to author
Forward
0 new messages