一把umbraco CMS(.NET):记录错误加载XSLT /用户控制 [英] Umbraco CMS(.NET): Logging errors loading xslt/User controls

查看:177
本文介绍了一把umbraco CMS(.NET):记录错误加载XSLT /用户控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果有一个在一把umbraco的方式来记录我们得到,当它加载失败或XSLT用户控件的错误。一般来说它显示了一个红色框说它无法加载控制和东西。有没有一种方法能够正常登录呢?

I was wondering if there's a way in Umbraco to log errors that we get when it fails to load xslt or user-controls. Generally it shows a red box saying it couldn't load the control and stuff. Is there a way to properly log this?

在此先感谢。

推荐答案

首先,这不是真的...支持发生错误时它输出HTML和写入asp.net跟踪日志。

First off, it's not really supported... When errors occur it outputs html and writes to the asp.net trace log.

继承人我会怎么处理这个。我的大多数一把umbraco的安装使用ELMAH异常记录和log4net的申请记录。这应该给你输出的任何错误。

Heres how I would approach this. Most of my Umbraco installations use Elmah for exception logging and log4net for application logging. This should give you any errors on output.

using System;
using System.Linq;
using System.Web;

public class MacroLogging : IHttpModule {

    public void Init(HttpApplication context) {
        context.LogRequest += ContextLogRequest;
    }

    static void ContextLogRequest(object source, EventArgs e) {
        var app = (HttpApplication)source;
        var context = app.Context;
        context.Trace.TraceFinished += TraceFinished;
    }

    static void TraceFinished(object sender, TraceContextEventArgs e) {
        var records = e.TraceRecords.Cast<TraceContextRecord>();
        var categoryTypes = new[] {"Macro", "macro", "umbracoMacro"};
        var traceOutput = records.Where(p => categoryTypes.Contains(p.Category) && p.IsWarning)));
        foreach (var entry in traceOutput) {
            //Your Output entry.Message
        }
    }

    public void Dispose() {}

}

刚刚模块添加到你的web.config。我have't测试,因为它是凌晨1点:)但整体的概念应该工作。

Just add the module to your web.config. I have't tested as it's 1am :) but the overall concept should work.

这篇关于一把umbraco CMS(.NET):记录错误加载XSLT /用户控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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