Q:

Why does logRequest not log requests?

According to the documentation, Spray allows user to log request and response.
However, for some reasons, I can't seem to make it work.
Here's what I have on the "routing side"
def generateRoute = pathPrefix("session") {
 logRequest("session reached") {
  path("new") {
    logRequest("session new reached") {
      post { entity(as[Initiate]) { sessionInfo =>
        logRequest("session new post reached") {
            complete("pass\n")
          }
        }
 /// the rest of the braces

Here's what I have in my configuration:
akka {
  loglevel = DEBUG
  loggers = ["akka.event.slf4j.Slf4jLogger"]
}

Here's what I see in my log:
app 11/29 13:02:35 DEBUG[sys-tracker-akka.actor.default-dispatcher-4] a.i.TcpListener - New connection accepted
app 11/29 13:02:36 DEBUG[sys-tracker-akka.actor.default-dispatcher-4] s.c.s.HttpServerConnection - Dispatching POST request to http://localhost:8080/session/new to handler Actor[akka://sys-tracker/system/IO-TCP/selectors/$a/1#2086889080]
app 11/29 13:02:36 DEBUG[sys-tracker-akka.actor.default-dispatcher-6] s.c.s.HttpServerConnection - Connection was PeerClosed, awaiting TcpConnection termination...
app 11/29 13:02:36 DEBUG[sys-tracker-akka.actor.default-dispatcher-4] s.c.s.HttpServerConnection - TcpConnection terminated, stopping

So, even though I have logRequest directives in my route, the request is not logged. Any ideas why?

A:

I have built a sample solution with spray-routing and just your route function and configuration. I do see log statements corresponding to your logRequest methods. The output includes both text passed to logRequest and HttpRequest. 
01:42:36.946 [SprayRoutingExample-akka.actor.default-dispatcher-2] DEBUG akka.actor.ActorSystemImpl - session new post reached: HttpRequest(POST,http://localhost:8080/session/new,List(Accept-Language: en-US, en, Accept-Encoding: gzip, deflate, Accept: */*, Content-Type: text/plain, Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo, User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36, Content-Length: 4, Connection: keep-alive, Host: localhost:8080),HttpEntity(text/plain,test),HTTP/1.1)

Try changing the log level for your call to see if that makes any difference
logRequest("session reached", akka.event.Logging.InfoLevel)

What do you use as concrete logger implementation. Check that your logger configuration is correct. I used logback.

