Last active
March 20, 2020 15:05
-
-
Save akeeton/e97e0eac3a6723e1ff67ca7f3fd47c0c to your computer and use it in GitHub Desktop.
F# version of https://stackoverflow.com/a/19538654/68086
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
open log4net.Appender | |
open log4net.Core | |
open log4net.Layout | |
open log4net.Repository.Hierarchy | |
let setup () : unit = | |
let hierarchy = LogManager.GetRepository() :?> Hierarchy | |
let patternLayout = PatternLayout() | |
patternLayout.ConversionPattern <- "%date [%thread] %-5level %logger - %message%newline" | |
patternLayout.ActivateOptions() | |
let roller = RollingFileAppender() | |
roller.AppendToFile <- false | |
roller.File <- @"Logs\EventLog.txt" | |
roller.Layout <- patternLayout | |
roller.MaxSizeRollBackups <- 5 | |
roller.MaximumFileSize <- "1GB" | |
roller.RollingStyle <- RollingFileAppender.RollingMode.Size | |
roller.StaticLogFileName <- true | |
roller.ActivateOptions() | |
hierarchy.Root.AddAppender(roller) | |
let memory = MemoryAppender() | |
memory.ActivateOptions() | |
hierarchy.Root.AddAppender(memory) | |
hierarchy.Root.Level <- Level.Info | |
hierarchy.Configured <- true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment