This is my dilemma. I have a RollingFileAppender
. I have a BufferingForwardingAppender
. The forwarding appender writes to the file appender. My file appender needs a file to write to. I want the file to be named as such %Called Assembly Type%log.txt
, where %Called Assembly Type% is the called assembly type (gasp!)
I'm intending to use this as follows:
Calling from a service called "OkilyDokily
":
var log4NetLogger = LogManager.GetLogger(GetMyAssemblyName());
log4NetLogger.LogInfo("Toodleoo");
Calling from a service called "Neighborinos
":
var log4NetLogger = LogManager.GetLogger(GetMyAssemblyName());
log4NetLogger.LogInfo("Toodleoo");
I expect to have 2 log files, one named OkilyDokilylog.txt
and one named Neighborinoslog.txt
Is there a way to do this in log4net? Is my BufferingForwardingAppender
going to be an issue? I have tried this configuration but %logger
is simply translating to the string logger
:(
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString">
<conversionPattern value="C:\testlogs\%logger log.txt" />
</file>
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="-1" />
<maximumFileSize value="5KB" />
<staticLogFileName value="true" />
<countDirection value="1"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-8level %-21date{M/d/yyyy H:m:ss} %message%newline" />
</layout>
</appender>