문제

I have a simple hello world happstack app:

module Main where

import Happstack.Server (nullConf, simpleHTTP, toResponse, ok)

main :: IO ()
main = simpleHTTP nullConf $ ok "Hello, World!"

I want it to log requests to stdout.

I found this http://happstack.wordpress.com/2009/02/26/happstack-now-outputs-apache-combined-logs/ which says it is outputting logs, but they are not going to stdout. I've never used hslogger before and am having trouble figuring how to a) configure it, and b) wire it into happstack. nullConf provides a default logMAccess, but it isn't clear how that ends up in hslogger.

도움이 되었습니까?

해결책

Just after I posted I found this: http://www.haskell.org/pipermail/beginners/2011-August/008184.html which gave me the clue I needed.

module Main where

import Happstack.Server (nullConf, simpleHTTP, toResponse, ok)

import System.IO
import System.Log.Logger ( updateGlobalLogger
                         , rootLoggerName
                         , setLevel
                         , Priority(..)
                         )

main :: IO ()
main = do
  updateGlobalLogger rootLoggerName (setLevel INFO)

  simpleHTTP nullConf $ ok "Hello, World!"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top