It is necessary to configure logging through the code.

I found this code and it works in general:

Sub Setup() Dim hierarchy = CType(LogManager.GetRepository(), Hierarchy) Dim patternLayout = New PatternLayout() patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline" patternLayout.ActivateOptions() Dim roller = New RollingFileAppender() roller.AppendToFile = False roller.File = "C:\EventLog.txt" roller.Layout = patternLayout roller.MaxSizeRollBackups = 5 roller.MaximumFileSize = "1GB" roller.RollingStyle = RollingFileAppender.RollingMode.Size roller.StaticLogFileName = True roller.ActivateOptions() roller.Name = "Log" hierarchy.Root.AddAppender(roller) Dim t = New LoggerMatchFilter() t.LoggerToMatch = "Log" t.AcceptOnMatch = True roller.AddFilter(t) hierarchy.Root.Level = Level.All hierarchy.Configured = True End Sub 

However, the problem is that messages from other rollers that I did not configure and do not want to see them in the file are written to the file log.

I called the roller as Log and tried to set a filter called Log, but nefig ...

What am I doing wrong?

    0