I have a C# WebApi application which stores log messages into ElasticSearch. I'm using the log4net library
This is one log record:
{
"_index" : "log-2016.06.23",
"_type" : "logEvent",
"_id" : "AVV9rAqpZnaTkXOWfRfY",
"_score" : 1.0,
"_source" : {
"timeStamp" : "2016-06-23T14:31:14.0610345Z",
"fileName" : "C:\\Users\\gianluca.ghettini\\Desktop\\EOS\\Eurotherm.Data\\Uhh\\UhhFileImporter.cs",
"lineNumber" : "1063",
"fullInfo" : "Eurotherm.Data.Uhh.UhhFileImporter.LogMessage(C:\\Users\\gianluca.ghettini\\Desktop\\EOS\\Eurotherm.Data\\Uhh\\UhhFileImporter.cs:1063)",
"methodName" : "LogMessage",
"threadName" : "7",
"hostName" : "GBWOTIOM68052D"
}
The methodName
is always "LogMessage
" instead of being the actual method that made the log line. That's because I wrapped the log4net library inside a convenience class.
Is there a way to tell log4net to use the caller method as the "methodName"?