I'm working with Orchard CMS and it is better CMS for me. I want to understand how it does the logging and whether I can add my own logging or not. I saw that Orchard uses NullLogger
class and it does no work. I've opened the App_Data.Logs folder and have seen that there are the log files. But how? I searched in code where is the trick that replaces NullLogger
with log4net (I guess this is log4net, because the log format and the formatting for log4net.config are very similar) but I haven't found this.
Can somebody answer me:
Thanks, Andrey.
An Autofac module (Orchard.Logging.LoggerModule
to be precise) handles that. Basically - it scans each dependency and fills all properties of type ILogger
with a reference to appropriate logger instance. Each dependency gets its own logger with name equal to full type name (including namespace) of a containing class.
The NullLogger
is just a placeholder so accessing the property would not throw NullReferenceException
s before the property is being set by Autofac.
Extending the default logging is a rather complicated task as it would involve doing three things:
LoggerModule
does)[OrchardSuppressDependency("Orchard.Logging.LoggingModule")]
UPDATE
Just realized I haven't addressed the most important part of the question here:) Yes, Orchard uses log4net so you may alter the default settings via Config/log4net.config file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With