I need to log this because my custom appender API is growing and requires tracking of possible errors and various states.
Using log within a custom appender will cause a recursive error being thrown I believe.
Is there any good/best practice to log info/errors within a custom appender?
A semaphore lock with FIleStream and FileWriter seems ok but it will lock up resources and slow the process if multiple processes are contending to write on the same log file.
Official source : http://logging.apache.org/log4net/release/faq.html
As suggested by stuartd, LogLog can be used for internal debugging.
First in ~.config file of the project, 2 things must be set.
1)
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
This enables internal debugging of log4net/j
2)
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add
name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\tmp\log4net.txt" />
</listeners>
</trace>
</system.diagnostics>
This enables windows machine to trace. 2 things to make sure.
a) the application folder needs to be there because it doesn't check if folder exists for the log file. If the folder is not there the file won't be created.
b) administrator rights of this program is required else the file cannot be written.
3)
log4net.Util.LogLog.Debug(null, "testing internal debug");
In the custom appender, simply use this to do internal logging. For the input parameter {0} i am not sure why it requires obj Type
. I will find out why and what is it's purpose.