Skip to content

Instantly share code, notes, and snippets.

@akeeton
Last active March 20, 2020 15:05
Show Gist options
  • Save akeeton/e97e0eac3a6723e1ff67ca7f3fd47c0c to your computer and use it in GitHub Desktop.
Save akeeton/e97e0eac3a6723e1ff67ca7f3fd47c0c to your computer and use it in GitHub Desktop.
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