|
VBのコードで申し訳ない・・・
Dim h As Hierarchy = CType(LogManager.GetRepository, Hierarchy)
h.LoggerFactory.CreateLogger("logger")
Dim logger As Logger
logger = h.GetLogger("logger", h.LoggerFactory)
Dim layout As log4net.Layout.PatternLayout = New log4net.Layout.PatternLayout
layout.ConversionPattern = "%d %-5p - %m%n"
layout.ActivateOptions()
Dim appender As FileAppender = New FileAppender()
appender.File = Application.StartupPath + "\test.log"
appender.Layout = layout
appender.AppendToFile = True
appender.ActivateOptions()
logger.AddAppender(appender)
logger.Level = Level.All
log4net.Config.BasicConfigurator.Configure(h, appender)
Dim log4 As ILog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
log4.Info("xxx")
以上。
|