You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "martinRocks (via GitHub)" <gi...@apache.org> on 2025/08/06 18:19:00 UTC
Re: [D] Support for template names [logging-log4net]
GitHub user martinRocks closed a discussion: Support for template names
When will log4net allow the use of template names? For example, a log message like this:
```_log.InfoFormat("Started {time}", DateTime.Now);```
so that the message comes out in Json format like this:
```
{
"date": "2025-06-27T12:09:20.6955070-04:00",
"level": "INFO",
"appname": "App.exe",
"logger": "Log",
"thread": "1",
"ndc": "(null)",
"message": {
"Format": "Started {time}",
"time": [
"2025-06-27T12:09:20.6935074-04:00"
]
}
}
```
I'm currently using the library log4net.Ext.Json to export the json. If this does work, please tell me how, because when I try it, I get the error:
```
log4net:WARN Exception while rendering format [Started {time}]
System.FormatException: Input string was not in a correct format.
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at log4net.Util.SystemStringFormat.StringFormat(IFormatProvider provider, String format, Object[] args) in /home/alle/git/apache/logging-log4net/src/log4net/Util/SystemStringFormat.cs:line 86
```
Also, I'm using these libraries.
log4net, version=3.1.0
log4net.Ext.Json, version=3.0.3
log4net.Ext.Json.Net, version=3.0.3
Newtonsoft.Json, version=13.0.3
GitHub link: https://github.com/apache/logging-log4net/discussions/261
----
This is an automatically sent email for dev@logging.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@logging.apache.org