-
Notifications
You must be signed in to change notification settings - Fork 32
Logging and Diagnostics
KitchenPC Core and DB use log4net internally. Applications configure appenders and levels; the libraries do not choose log destinations.
Add a log4net.config file:
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="Console" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%level] %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="WARN" />
<appender-ref ref="Console" />
</root>
<logger name="KitchenPC.Core.NLP.Parser">
<level value="INFO" />
</logger>
</log4net>Initialize log4net according to the hosting model before context startup. In modern .NET, one option is:
log4net.Config.XmlConfigurator.Configure(
new FileInfo("log4net.config"));Database import/export, NHibernate, Npgsql, and the modeler have their own logger categories. Start at WARN, temporarily raise only the category being diagnosed, and avoid logging connection strings or user-entered recipe data in production.
Ordinary parser logging summarizes activity. NLP tracing records grammar templates, synonym resolution, form pairing, anomaly fallbacks, and failure decisions:
using KitchenPC.Core.NLP;
NlpTracer.SetTracer(new DefaultTracer());
var result = context.ParseIngredientUsage("a dozen bananas");For another destination, implement ITracer and pass it to SetTracer. The interface receives trace level, format string, and arguments. Because tracing is global and extremely verbose, configure it once and use it only for focused diagnostics.
Useful operational signals include:
- context initialization duration and selected capabilities;
- recipe search duration, result count, and sanitized filter summary;
- NLP status counts without raw personal data;
- provisioning/import phase and record counts;
- missing-capability and incompatible-amount exceptions;
- database connectivity and timeout failures.
- Preserve the original input and
Result.Status. - Enable an NLP tracer in a safe development environment.
- Check ingredient and synonym presence.
- Check the default form pairing for the parsed unit type.
- Check form/unit compatibility and custom-unit mappings.
- Improve source metadata instead of hard-coding UI-only exceptions when the rule is generally valid.
KitchenPC is MIT licensed. Runnable applications live in KitchenPC/Samples.