Created
May 9, 2017 15:04
-
-
Save cboudereau/20c5a5e2e73815b7eb49e448e7f66d61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let log = Log.logger "WebService" | |
let logger = | |
let convertLevel = function | |
| Logging.LogLevel.Debug -> LogLevel.Debug | |
| Logging.LogLevel.Verbose -> LogLevel.Trace | |
| Logging.LogLevel.Info -> LogLevel.Info | |
| Logging.LogLevel.Warn -> LogLevel.Warn | |
| Logging.LogLevel.Error -> LogLevel.Error | |
| Logging.LogLevel.Fatal -> LogLevel.Fatal | |
let log = LogManager.GetLogger("WebService") | |
let culture = Globalization.CultureInfo.InvariantCulture | |
{ new Logging.Logger with | |
member __.Log(level: Logging.LogLevel) (msg: unit -> Logging.LogLine): unit = | |
let lvl = convertLevel level | |
if log.IsEnabled lvl then | |
let line = msg() | |
match line.``exception`` with | |
| None -> log.Log(LogEventInfo(lvl, line.path, culture, line.message, null)) | |
| Some ex-> log.Log(LogEventInfo(lvl, line.path, culture, line.message, null, ex)) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment