Hello, I found the answer myself.
EventContext layoutrenderer will do the trick:
// target configuration
DatabaseTarget target = new DatabaseTarget();
[....] //target configuration
target.CommandText = "insert into LogTable(time_stamp,level,message,category) values(@time_stamp, @level, @message, @category);";
[....] //common parameters
target.Parameters.Add(new DatabaseParameterInfo("@category", "${event-context:item=category}"));
//runtime logging:
NLog.Logger theLog = NLog.LogManager.GetLogger("Example");
NLog.LogEventInfo theEvent = new NLog.LogEventInfo(NLog.LogLevel.Trace, "", "This is my log message");
theEvent.Context["category"] = "12345";
theLog.Log(theEvent);
I hope this can be useful to any of you.
Anyway I agreee with Jamison (
http://n2.nabble.com/event-context-needs-more-documentation-td1685980.html#a1685980) saying that EventContext is a very powerful layout renderer and therefore needs more documentation.
CHEERS