[Haskell-beginners] hslogger question

Manfred Lotz manfred.lotz at arcor.de
Sat Aug 6 21:43:17 CEST 2011


Hi there,
Using hslogger I want to get
 - error messages and above to stdout and to logfile
 - debug messages and above to logfile only.


Here is what I tried:


import System.Log.Logger
import System.Log.Handler.Simple
import System.Log.Handler (setFormatter)
import System.Log.Formatter


-- By default, all messages of level WARNING and above are sent to
stderr. -- Everything else is ignored.

main :: IO ()
main = do
  -- all messages of level ERROR and above to stderr.
  updateGlobalLogger rootLoggerName (setLevel ERROR)

  h <- fileHandler "debug.log" DEBUG >>= \lh -> return $
                 setFormatter lh (simpleLogFormatter "[$time :
  $loggername : $prio] $msg") updateGlobalLogger rootLoggerName
  (addHandler h)

  errorM "MyApp.Init" "This is a bad error"

  -- This message will go to logfile only. 
  debugM "MyApp.Main" "This buggy component is buggy"

  -- This message will go to logfile only. 
  warningM "MyApp.Finish" "Still Buggy"


errorM goes to stderr and logfile as expected. However, debugM and
warningM are not to be seen at all. 


What am I doing wrong?




-- 
Manfred





More information about the Beginners mailing list