果园CMS如何记录? [英] How Orchard CMS does the logging?

查看:255
本文介绍了果园CMS如何记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与果园CMS工作,最好是CMS我。我想了解它是如何做的记录和我是否可以添加自己的日志记录或没有。我看到果园使用 NullLogger 类和它没有工作。我已经打开了App_Data.Logs文件夹,看到有日志文件。但是如何?我搜索在code其中替换的伎俩 NullLogger 与log4net的(我猜这是log4net的,因为日志格式和log4net.config的格式非常相似),但我还没有发现这一点。
谁能回答我:

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:


  1. 果园如何记录?

  2. 我是否可以添加自己的记录,如果是哪些最佳实践存在这样做呢?

谢谢,安德烈。

推荐答案

这是Autofac模块( Orchard.Logging.LoggerModule 是precise)处理的。基本上 - 它扫描每个依赖和填充型 ILogger 的所有属性与适当的记录器实例的引用。每个依赖都有自己的记录是名称等于完整的类型名(包括命名空间)含有类

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.

NullLogger 只是一个占位符,以便访问属性不会抛出的NullReferenceException s被正在设置的属性前通过Autofac。

The NullLogger is just a placeholder so accessing the property would not throw NullReferenceExceptions before the property is being set by Autofac.

扩展默认的日志记录是一个相当复杂的任务,因为这将涉及到做三件事情:

Extending the default logging is a rather complicated task as it would involve doing three things:


  • 创建ILoggerFactory (就像默认Orchard.Logging.CastleLoggerFactory)的自定义实现和

  • 创建一个Autofac模块的注册,在容器实现(如提到的 LoggerModule 一样)

  • 燮preSS当前默认的日志模块按装饰你的新的使用 [OrchardSup pressDependency(Orchard.Logging.LoggingModule)]

  • create a custom implementation of ILoggerFactory (just like the default Orchard.Logging.CastleLoggerFactory) and
  • create an Autofac module that registers that implementation in the container (like the mentioned LoggerModule does)
  • suppress the current default logging module by decorating your new one with [OrchardSuppressDependency("Orchard.Logging.LoggingModule")]

更新

刚刚意识到我没有在这里解决问题的最重要的部分:)
是的,果园使用log4net的,所以你可以通过修改默认设置的配置/ log4net.config 的文件。

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.

这篇关于果园CMS如何记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆