Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use NLog ILogger.Error(Exception, String,Object[])

Tags:

nlog

NLog has a method ILogger.Error(Exception, String,Object[]) See Ref.

What kind of layout renderer can I use to log the args Object[]?

Alternatively, is there any other way to log all local variables?

like image 921
Dharmendar Kumar 'DK' Avatar asked Apr 10 '26 14:04

Dharmendar Kumar 'DK'


1 Answers

The args Object[] will be included in the message as format string arguments.

So NLog calls string.Format(message, args) where messages is your log message and args are the "fillers" in that message.

Then this formatted message can be accessed with the ${message} layout render to include in your logs.

I'm not aware of any automatic logging of local variables so you need to pass them manually to the Error method using the args parameter.

like image 102
nemesv Avatar answered Apr 29 '26 17:04

nemesv