What's wrong with my log4net config file -
i have config file 2 appenders, 1 file appender , 1 database appender. want log file appender, , log exceptions database appender. when setting both appenders in section logs fine log events sent both appenders, not want.
i changed configuration current configuration, exceptions logged database, , nothing getting written file appender. can tell me why not getting written file appender?
<log4net debug="true"> <appender name="rollinglogfileappender" type="log4net.appender.rollingfileappender"> <file value="c:\log4net\workflow\testlog.txt" /> <threshold value="all" /> <appendtofile value="true" /> <rollingstyle value="size" /> <maxsizerollbackups value="10" /> <maximumfilesize value="10kb" /> <staticlogfilename value="true" /> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%-5p {%logger} %d %5rms %-22.22c{1} %-18.18m - %m%n" /> </layout> </appender> <appender name="adonetappender" type="log4net.appender.adonetappender"> <!-- removed keep snippet simple--> </appender> <root> <level value="error" /> <appender-ref ref="adonetappender" /> </root> <logger name="alllogs"> <level value="all" /> <appender-ref ref="rollinglogfileappender" /> </logger> </log4net>
what have here following:
- all logs events level
error
or more goadonetappender
- all logs events originating logger name based on
alllogs
gorollinglogfileappender
from understand want logs default file, , error ones go database. add both appenders root logger both events, , add filters let filters you're interested in pass through: level range filter on database appender work
<log4net debug="true"> <appender name="rollinglogfileappender" type="log4net.appender.rollingfileappender"> <!-- rest of config snipped save space --> </appender> <appender name="adonetappender" type="log4net.appender.adonetappender"> <filter type="log4net.filter.levelrangefilter"> <levelmin value="error" /> <levelmax value="fatal" /> </filter> <!-- rest of config snipped save space --> </appender> <root> <appender-ref ref="adonetappender" /> <appender-ref ref="rollinglogfileappender" /> </root> </log4net>
of course if don't want duplicate filter errors , above in rolling file appender
Comments
Post a Comment