You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Patrick Schulz (Jira)" <ji...@apache.org> on 2022/07/08 10:11:00 UTC
[jira] [Commented] (LOG4NET-686) AdoNetAppender not working over SQL server
[ https://issues.apache.org/jira/browse/LOG4NET-686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17564214#comment-17564214 ]
Patrick Schulz commented on LOG4NET-686:
----------------------------------------
We had this issue too with v2.0.14.
I enabled debug logging and stumpled upon the error "System.InvalidOperationException: variable length parameters have to be explicit non-null-size" (or so) thrown by SqlCommand.Prepare().
Here the exact message in german: System.InvalidOperationException: "Die SqlCommand.Prepare-Methode erfordert, dass für alle variablen Längenparameter explizit eine nicht-Null-Size festgelegt wird."
Solution: Create a custom AdoNetAppender and overwrite the existing Prepare(IDbCommand dbCmd)-Method with:
```
foreach(var o in base.m_parameters){
var parameter = (AdoNetAppenderParameter) o;
parameter.Prepare(dbCmd);
}
```
And it works (for us) again.
> AdoNetAppender not working over SQL server
> ------------------------------------------
>
> Key: LOG4NET-686
> URL: https://issues.apache.org/jira/browse/LOG4NET-686
> Project: Log4net
> Issue Type: Bug
> Components: Builds
> Affects Versions: 2.0.14
> Environment: Windows 10 Pro N, 21H2
> .NET framework 4.7.1
> Reporter: Hugues Stefanski
> Priority: Major
> Attachments: Log4NetTest.zip
>
>
> Hello,
> Following an update of our dependencies, I noticed that my log traces are not getting output to SQL server anymore. I created a test project (attached to this issue), with the same configuration, using v2.0.12 and v2.0.14, and confirmed that 2.0.12 worked as expected, while 2.0.14 does not write anything.
>
> Checking the release notes, I stumbled on [PR 77|https://github.com/apache/logging-log4net/pull/77], which I guess might be related (but that's just a wild guess)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)