umco / umbraco-stacked-content

Stacked Content for Umbraco 7
https://our.umbraco.org/projects/backoffice-extensions/stacked-content
MIT License
17 stars 27 forks source link

Ability to enable/disable warnings for template not found #59

Closed NikRimington closed 5 years ago

NikRimington commented 5 years ago

Hey wonderful Umco peeps :-)

I'm getting a lot of the following in my logs:

`No view found for partial {partial name here}`

I was just thinking it would be nice if there was a setting to enable/disable this warning from being logged. It's a useful warning at development time, but at deployment it feels more like noise in the logs. I do keep warnings logged as I find they often contain useful information relating to errors in the Umbraco Core so don't really want to change the logging level on the site.

Just a thought :-)

leekelleher commented 5 years ago

Thanks @NikRimington, I dislike bloated logs too!

What's your set-up with Stacked Content, is preview enabled and only a few blocks have a partial-view?


I have a couple of thoughts about it...

  1. I'm wondering how we can have a toggle for disabling logging - but then that might seem overkill since we only use logging in a couple of places. I wouldn't want an option in the data-type itself. Maybe we check if the web-app is in debug mode?

  2. You could change the log level for specific namespaces in the log4net config? e.g.

<logger name="Our.Umbraco.StackedContent">
    <level value="ERROR" />
</logger>

Note: I haven't tested this. It may need a more explicit namespace, e.g. "Our.Umbraco.StackedContent.Web.Helpers".

NikRimington commented 5 years ago

I have mainly preview-able blocks but a few that don't need a preview / preview unnecessarily complex for the back office. An example is a "Social media feed" block that pulls in a dedicated twitter feed.

One option is I go ahead and create previews for these. Just think it would be nice to not have to :-)

I agree the option shouldn't be on the datatype, I was thinking more along the lines of an app setting for StackedContent that allows you to switch Missing Preview Template Warnings on or off (name needs work). It would be fairly simple, clean, and easy to configure :-)

I don't know much about log4net log levels to be fair, so can't comment on that idea :-)

leekelleher commented 5 years ago

@NikRimington My log4net suggestion is something that you could try out as an immediate workaround. It'll stop the warnings being constantly logged.

Thinking about a fix for the issue itself. I'm hesitant to add in a toggle, (in the pursuit of "simplicity" - whatever that means 😉).

Current thought is to keep track of the missing partials and only log the warning once, (per app life-cycle). Of course, you'd still get a bunch of warnings in the log at first, but then they'd be muted.

@mattbrailsford Any thoughts on this?

leekelleher commented 5 years ago

I've made a branch/PR #60 for my proposed fix. If that works as a happy compromise?

NikRimington commented 5 years ago

For me that would work. It's useful to know so the occasional logging (e.g. after a an app pool recycle) isn't an issue. Think it's a good option.

leekelleher commented 5 years ago

Cool 👍 I'll close this one off, and chat with Matt about PR #60